Lines Matching full:llvm
1 //===------- CGObjCGNU.cpp - Emit LLVM Code from ASTs for a Module --------===//
3 // The LLVM Compiler Infrastructure
28 #include "llvm/ADT/SmallVector.h"
29 #include "llvm/ADT/StringMap.h"
30 #include "llvm/IR/DataLayout.h"
31 #include "llvm/IR/Intrinsics.h"
32 #include "llvm/IR/LLVMContext.h"
33 #include "llvm/IR/Module.h"
34 #include "llvm/Support/CallSite.h"
35 #include "llvm/Support/Compiler.h"
49 std::vector<llvm::Type*> ArgTys;
51 llvm::Constant *Function;
62 llvm::Type *RetTy, ...) {
69 while (llvm::Type *ArgTy = va_arg(Args, llvm::Type*))
76 /// LLVM constant.
77 operator llvm::Constant*() {
81 llvm::Type *RetTy = ArgTys.back();
83 llvm::FunctionType *FTy = llvm::FunctionType::get(RetTy, ArgTys, false);
85 cast<llvm::Constant>(CGM->CreateRuntimeFunction(FTy, FunctionName));
92 operator llvm::Function*() {
93 return cast<llvm::Function>((llvm::Constant*)*this);
104 /// The LLVM module into which output is inserted
105 llvm::Module &TheModule;
108 llvm::StructType *ObjCSuperTy;
111 llvm::PointerType *PtrToObjCSuperTy;
112 /// LLVM type for selectors. Opaque pointer (i8*) unless a header declaring
115 llvm::PointerType *SelectorTy;
116 /// LLVM i8 type. Cached here to avoid repeatedly getting it in all of the
118 llvm::IntegerType *Int8Ty;
119 /// Pointer to i8 - LLVM type of char*, for all of the places where the
121 llvm::PointerType *PtrToInt8Ty;
127 llvm::PointerType *IMPTy;
132 llvm::PointerType *IdTy;
135 llvm::PointerType *PtrToIdTy;
139 /// LLVM type for C int type.
140 llvm::IntegerType *IntTy;
141 /// LLVM type for an opaque pointer. This is identical to PtrToInt8Ty, but is
144 llvm::PointerType *PtrTy;
145 /// LLVM type for C long type. The runtime uses this in a lot of places where
148 llvm::IntegerType *LongTy;
149 /// LLVM type for C size_t. Used in various runtime data structures.
150 llvm::IntegerType *SizeTy;
151 /// LLVM type for C intptr_t.
152 llvm::IntegerType *IntPtrTy;
153 /// LLVM type for C ptrdiff_t. Mainly used in property accessor functions.
154 llvm::IntegerType *PtrDiffTy;
155 /// LLVM type for C int*. Used for GCC-ABI-compatible non-fragile instance
157 llvm::PointerType *PtrToIntTy;
158 /// LLVM type for Objective-C BOOL type.
159 llvm::Type *BoolTy;
161 llvm::IntegerType *Int32Ty;
163 llvm::IntegerType *Int64Ty;
165 /// runtime provides some LLVM passes that can use this to do things like
171 llvm::Constant *MakeConstantString(const std::string &Str,
173 llvm::Constant *ConstStr = CGM.GetAddrOfConstantCString(Str, Name.c_str());
174 return llvm::ConstantExpr::getGetElementPtr(ConstStr, Zeros);
180 llvm::Constant *ExportUniqueString(const std::string &Str,
183 llvm::Constant *ConstStr = TheModule.getGlobalVariable(name);
185 llvm::Constant *value = llvm::ConstantDataArray::getString(VMContext,Str);
186 ConstStr = new llvm::GlobalVariable(TheModule, value->getType(), true,
187 llvm::GlobalValue::LinkOnceODRLinkage, value, prefix + Str);
189 return llvm::ConstantExpr::getGetElementPtr(ConstStr, Zeros);
194 llvm::GlobalVariable *MakeGlobal(llvm::StructType *Ty,
195 ArrayRef<llvm::Constant *> V,
197 llvm::GlobalValue::LinkageTypes linkage
198 =llvm::GlobalValue::InternalLinkage) {
199 llvm::Constant *C = llvm::ConstantStruct::get(Ty, V);
200 return new llvm::GlobalVariable(TheModule, Ty, false,
206 llvm::GlobalVariable *MakeGlobal(llvm::ArrayType *Ty,
207 ArrayRef<llvm::Constant *> V,
209 llvm::GlobalValue::LinkageTypes linkage
210 =llvm::GlobalValue::InternalLinkage) {
211 llvm::Constant *C = llvm::ConstantArray::get(Ty, V);
212 return new llvm::GlobalVariable(TheModule, Ty, false,
217 llvm::GlobalVariable *MakeGlobalArray(llvm::Type *Ty,
218 ArrayRef<llvm::Constant *> V,
220 llvm::GlobalValue::LinkageTypes linkage
221 =llvm::GlobalValue::InternalLinkage) {
222 llvm::ArrayType *ArrayTy = llvm::ArrayType::get(Ty, V.size());
226 llvm::Constant *MakePropertyEncodingString(const ObjCPropertyDecl *PD,
240 return llvm::ConstantExpr::getGetElementPtr(
246 void PushPropertyAttributes(std::vector<llvm::Constant*> &Fields,
258 Fields.push_back(llvm::ConstantInt::get(Int8Ty, attrs & 0xff));
268 Fields.push_back(llvm::ConstantInt::get(Int8Ty, attrs & 0xff));
270 Fields.push_back(llvm::ConstantInt::get(Int8Ty, 0));
271 Fields.push_back(llvm::ConstantInt::get(Int8Ty, 0));
276 llvm::Value* EnforceType(CGBuilderTy &B, llvm::Value *V, llvm::Type *Ty) {
281 llvm::Constant *Zeros[2];
283 llvm::Constant *NULLPtr;
284 /// LLVM context.
285 llvm::LLVMContext &VMContext;
291 llvm::GlobalAlias *ClassPtrAlias;
296 llvm::GlobalAlias *MetaClassPtrAlias;
298 std::vector<llvm::Constant*> Classes;
300 std::vector<llvm::Constant*> Categories;
303 std::vector<llvm::Constant*> ConstantStrings;
307 llvm::StringMap<llvm::Constant*> ObjCStrings;
309 llvm::StringMap<llvm::Constant*> ExistingProtocols;
315 typedef std::pair<std::string, llvm::GlobalAlias*> TypedSelector;
319 typedef llvm::DenseMap<Selector, SmallVector<TypedSelector, 2> >
386 llvm::Constant *GenerateIvarList(ArrayRef<llvm::Constant *> IvarNames,
387 ArrayRef<llvm::Constant *> IvarTypes,
388 ArrayRef<llvm::Constant *> IvarOffsets);
394 llvm::Constant *GenerateMethodList(const StringRef &ClassName,
397 ArrayRef<llvm::Constant *> MethodTypes,
402 llvm::Constant *GenerateEmptyProtocol(const std::string &ProtocolName);
405 llvm::Constant *GeneratePropertyList(const ObjCImplementationDecl *OID,
407 SmallVectorImpl<llvm::Constant*> &InstanceMethodTypes);
410 llvm::Constant *GenerateProtocolList(ArrayRef<std::string> Protocols);
417 llvm::Constant *GenerateClassStructure(
418 llvm::Constant *MetaClass,
419 llvm::Constant *SuperClass,
422 llvm::Constant *Version,
423 llvm::Constant *InstanceSize,
424 llvm::Constant *IVars,
425 llvm::Constant *Methods,
426 llvm::Constant *Protocols,
427 llvm::Constant *IvarOffsets,
428 llvm::Constant *Properties,
429 llvm::Constant *StrongIvarBitmap,
430 llvm::Constant *WeakIvarBitmap,
434 llvm::Constant *GenerateProtocolMethodList(
435 ArrayRef<llvm::Constant *> MethodNames,
436 ArrayRef<llvm::Constant *> MethodTypes);
439 llvm::Value *GetSelector(CodeGenFunction &CGF, Selector Sel,
442 llvm::GlobalVariable *ObjCIvarOffsetVariable(const ObjCInterfaceDecl *ID,
449 virtual llvm::Value *GetClassNamed(CodeGenFunction &CGF,
454 virtual llvm::Value *LookupIMP(CodeGenFunction &CGF,
455 llvm::Value *&Receiver,
456 llvm::Value *cmd,
457 llvm::MDNode *node,
462 virtual llvm::Value *LookupIMPSuper(CodeGenFunction &CGF,
463 llvm::Value *ObjCSuper,
464 llvm::Value *cmd,
477 llvm::Constant *MakeBitField(ArrayRef<bool> bits);
482 virtual llvm::Constant *GenerateConstantString(const StringLiteral *);
489 llvm::Value *Receiver,
500 llvm::Value *Receiver,
504 virtual llvm::Value *GetClass(CodeGenFunction &CGF,
506 virtual llvm::Value *GetSelector(CodeGenFunction &CGF, Selector Sel,
508 virtual llvm::Value *GetSelector(CodeGenFunction &CGF, const ObjCMethodDecl
510 virtual llvm::Constant *GetEHType(QualType T);
512 virtual llvm::Function *GenerateMethod(const ObjCMethodDecl *OMD,
517 virtual llvm::Value *GenerateProtocolRef(CodeGenFunction &CGF,
520 virtual llvm::Function *ModuleInitFunction();
521 virtual llvm::Constant *GetPropertyGetFunction();
522 virtual llvm::Constant *GetPropertySetFunction();
523 virtual llvm::Constant *GetOptimizedPropertySetFunction(bool atomic,
525 virtual llvm::Constant *GetSetStructFunction();
526 virtual llvm::Constant *GetGetStructFunction();
527 virtual llvm::Constant *GetCppAtomicObjectGetFunction();
528 virtual llvm::Constant *GetCppAtomicObjectSetFunction();
529 virtual llvm::Constant *EnumerationMutationFunction();
538 virtual llvm::Value * EmitObjCWeakRead(CodeGenFunction &CGF,
539 llvm::Value *AddrWeakObj);
541 llvm::Value *src, llvm::Value *dst);
543 llvm::Value *src, llvm::Value *dest,
546 llvm::Value *src, llvm::Value *dest,
547 llvm::Value *ivarOffset);
549 llvm::Value *src, llvm::Value *dest);
551 llvm::Value *DestPtr,
552 llvm::Value *SrcPtr,
553 llvm::Value *Size);
556 llvm::Value *BaseValue,
559 virtual llvm::Value *EmitIvarOffset(CodeGenFunction &CGF,
562 virtual llvm::Value *EmitNSAutoreleasePoolClassRef(CodeGenFunction &CGF);
563 virtual llvm::Constant *BuildGCBlockLayout(CodeGenModule &CGM,
567 virtual llvm::Constant *BuildRCBlockLayout(CodeGenModule &CGM,
572 virtual llvm::Constant *BuildByrefLayout(CodeGenModule &CGM,
577 virtual llvm::GlobalVariable *GetClassGlobal(const std::string &Name) {
598 virtual llvm::Value *LookupIMP(CodeGenFunction &CGF,
599 llvm::Value *&Receiver,
600 llvm::Value *cmd,
601 llvm::MDNode *node,
604 llvm::Value *args[] = {
607 llvm::CallSite imp = CGF.EmitRuntimeCallOrInvoke(MsgLookupFn, args);
611 virtual llvm::Value *LookupIMPSuper(CodeGenFunction &CGF,
612 llvm::Value *ObjCSuper,
613 llvm::Value *cmd,
616 llvm::Value *lookupArgs[] = {EnforceType(Builder, ObjCSuper,
655 llvm::Type *SlotTy;
657 virtual llvm::Constant *GetEHType(QualType T);
659 virtual llvm::Value *LookupIMP(CodeGenFunction &CGF,
660 llvm::Value *&Receiver,
661 llvm::Value *cmd,
662 llvm::MDNode *node,
665 llvm::Function *LookupFn = SlotLookupFn;
668 llvm::Value *ReceiverPtr = CGF.CreateTempAlloca(Receiver->getType());
671 llvm::Value *self;
676 self = llvm::ConstantPointerNull::get(IdTy);
682 llvm::Value *args[] = {
686 llvm::CallSite slot = CGF.EmitRuntimeCallOrInvoke(LookupFn, args);
691 llvm::Value *imp =
699 virtual llvm::Value *LookupIMPSuper(CodeGenFunction &CGF,
700 llvm::Value *ObjCSuper,
701 llvm::Value *cmd,
704 llvm::Value *lookupArgs[] = {ObjCSuper, cmd};
706 llvm::CallInst *slot =
716 llvm::StructType *SlotStructTy = llvm::StructType::get(PtrTy,
718 SlotTy = llvm::PointerType::getUnqual(SlotStructTy);
727 llvm::Type *VoidTy = llvm::Type::getVoidTy(VMContext);
736 llvm::Type *VoidTy = llvm::Type::getVoidTy(VMContext);
745 llvm::Type *VoidTy = llvm::Type::getVoidTy(VMContext);
763 virtual llvm::Constant *GetCppAtomicObjectGetFunction() {
770 virtual llvm::Constant *GetCppAtomicObjectSetFunction() {
777 virtual llvm::Constant *GetOptimizedPropertySetFunction(bool atomic,
814 virtual llvm::Value *LookupIMP(CodeGenFunction &CGF,
815 llvm::Value *&Receiver,
816 llvm::Value *cmd,
817 llvm::MDNode *node,
820 llvm::Value *args[] = {
824 llvm::CallSite imp;
834 virtual llvm::Value *LookupIMPSuper(CodeGenFunction &CGF,
835 llvm::Value *ObjCSuper,
836 llvm::Value *cmd,
839 llvm::Value *lookupArgs[] = {EnforceType(Builder, ObjCSuper,
848 virtual llvm::Value *GetClassNamed(CodeGenFunction &CGF,
857 llvm::GlobalVariable *ClassSymbol = TheModule.getGlobalVariable(SymbolName);
860 ClassSymbol = new llvm::GlobalVariable(TheModule, LongTy, false,
861 llvm::GlobalValue::ExternalLinkage,
892 llvm::GlobalVariable *ClassSymbol = TheModule.getGlobalVariable(symbolName);
894 ClassSymbol = new llvm::GlobalVariable(TheModule, LongTy, false,
895 llvm::GlobalValue::ExternalLinkage, 0, symbolName);
897 new llvm::GlobalVariable(TheModule, ClassSymbol->getType(), true,
898 llvm::GlobalValue::WeakAnyLinkage, ClassSymbol, symbolRef);
920 IntTy = cast<llvm::IntegerType>(
922 LongTy = cast<llvm::IntegerType>(
924 SizeTy = cast<llvm::IntegerType>(
926 PtrDiffTy = cast<llvm::IntegerType>(
930 Int8Ty = llvm::Type::getInt8Ty(VMContext);
932 PtrToInt8Ty = llvm::PointerType::getUnqual(Int8Ty);
934 Zeros[0] = llvm::ConstantInt::get(LongTy, 0);
936 NULLPtr = llvm::ConstantPointerNull::get(PtrToInt8Ty);
942 SelectorTy = cast<llvm::PointerType>(CGM.getTypes().ConvertType(selTy));
945 PtrToIntTy = llvm::PointerType::getUnqual(IntTy);
948 Int32Ty = llvm::Type::getInt32Ty(VMContext);
949 Int64Ty = llvm::Type::getInt64Ty(VMContext);
952 TheModule.getPointerSize() == llvm::Module::Pointer32 ? Int32Ty : Int64Ty;
959 IdTy = cast<llvm::PointerType>(CGM.getTypes().ConvertType(ASTIdTy));
963 PtrToIdTy = llvm::PointerType::getUnqual(IdTy);
965 ObjCSuperTy = llvm::StructType::get(IdTy, IdTy, NULL);
966 PtrToObjCSuperTy = llvm::PointerType::getUnqual(ObjCSuperTy);
968 llvm::Type *VoidTy = llvm::Type::getVoidTy(VMContext);
996 llvm::Type *IMPArgs[] = { IdTy, SelectorTy };
997 IMPTy = llvm::PointerType::getUnqual(llvm::FunctionType::get(IdTy, IMPArgs,
1035 llvm::Value *CGObjCGNU::GetClassNamed(CodeGenFunction &CGF,
1038 llvm::Value *ClassName = CGM.GetAddrOfConstantCString(Name);
1044 // Libobjc2 contains an LLVM pass that replaces calls to objc_lookup_class
1050 llvm::Constant *ClassLookupFn =
1051 CGM.CreateRuntimeFunction(llvm::FunctionType::get(IdTy, PtrToInt8Ty, true),
1058 llvm::Value *CGObjCGNU::GetClass(CodeGenFunction &CGF,
1062 llvm::Value *CGObjCGNU::EmitNSAutoreleasePoolClassRef(CodeGenFunction &CGF) {
1066 llvm::Value *CGObjCGNU::GetSelector(CodeGenFunction &CGF, Selector Sel,
1070 llvm::GlobalAlias *SelValue = 0;
1081 SelValue = new llvm::GlobalAlias(SelectorTy,
1082 llvm::GlobalValue::PrivateLinkage,
1089 llvm::Value *tmp = CGF.CreateTempAlloca(SelValue->getType());
1096 llvm::Value *CGObjCGNU::GetSelector(CodeGenFunction &CGF, Selector Sel,
1101 llvm::Value *CGObjCGNU::GetSelector(CodeGenFunction &CGF,
1108 llvm::Constant *CGObjCGNU::GetEHType(QualType T) {
1129 llvm::Constant *CGObjCGNUstep::GetEHType(QualType T) {
1139 llvm::Constant *IDEHType =
1143 new llvm::GlobalVariable(CGM.getModule(), PtrToInt8Ty,
1145 llvm::GlobalValue::ExternalLinkage,
1147 return llvm::ConstantExpr::getBitCast(IDEHType, PtrToInt8Ty);
1160 llvm::Constant *typeinfo = TheModule.getGlobalVariable(typeinfoName);
1162 return llvm::ConstantExpr::getBitCast(typeinfo, PtrToInt8Ty);
1170 llvm::Constant *Vtable = TheModule.getGlobalVariable(vtableName);
1172 Vtable = new llvm::GlobalVariable(TheModule, PtrToInt8Ty, true,
1173 llvm::GlobalValue::ExternalLinkage, 0, vtableName);
1175 llvm::Constant *Two = llvm::ConstantInt::get(IntTy, 2);
1176 Vtable = llvm::ConstantExpr::getGetElementPtr(Vtable, Two);
1177 Vtable = llvm::ConstantExpr::getBitCast(Vtable, PtrToInt8Ty);
1179 llvm::Constant *typeName =
1182 std::vector<llvm::Constant*> fields;
1185 llvm::Constant *TI =
1186 MakeGlobal(llvm::StructType::get(PtrToInt8Ty, PtrToInt8Ty,
1188 llvm::GlobalValue::LinkOnceODRLinkage);
1189 return llvm::ConstantExpr::getBitCast(TI, PtrToInt8Ty);
1193 llvm::Constant *CGObjCGNU::GenerateConstantString(const StringLiteral *SL) {
1198 llvm::StringMap<llvm::Constant*>::iterator old = ObjCStrings.find(Str);
1209 llvm::Constant *isa = TheModule.getNamedGlobal(Sym);
1212 isa = new llvm::GlobalVariable(TheModule, IdTy, /* isConstant */false,
1213 llvm::GlobalValue::ExternalWeakLinkage, 0, Sym);
1215 isa = llvm::ConstantExpr::getBitCast(isa, PtrToIdTy);
1217 std::vector<llvm::Constant*> Ivars;
1220 Ivars.push_back(llvm::ConstantInt::get(IntTy, Str.size()));
1221 llvm::Constant *ObjCStr = MakeGlobal(
1222 llvm::StructType::get(PtrToIdTy, PtrToInt8Ty, IntTy, NULL),
1224 ObjCStr = llvm::ConstantExpr::getBitCast(ObjCStr, PtrToInt8Ty);
1240 llvm::Value *Receiver,
1255 llvm::Value *cmd = GetSelector(CGF, Sel);
1266 llvm::Value *ReceiverClass = 0;
1268 llvm::Constant *classLookupFunction = 0;
1270 classLookupFunction = CGM.CreateRuntimeFunction(llvm::FunctionType::get(
1273 classLookupFunction = CGM.CreateRuntimeFunction(llvm::FunctionType::get(
1286 MetaClassPtrAlias = new llvm::GlobalAlias(IdTy,
1287 llvm::GlobalValue::InternalLinkage, ".objc_metaclass_ref" +
1293 ClassPtrAlias = new llvm::GlobalAlias(IdTy,
1294 llvm::GlobalValue::InternalLinkage, ".objc_class_ref" +
1302 llvm::PointerType::getUnqual(
1303 llvm::StructType::get(IdTy, IdTy, NULL)));
1309 llvm::StructType *ObjCSuperTy = llvm::StructType::get(
1311 llvm::Value *ObjCSuper = Builder.CreateAlloca(ObjCSuperTy);
1319 llvm::Value *imp = LookupIMPSuper(CGF, ObjCSuper, cmd, MSI);
1322 llvm::Value *impMD[] = {
1323 llvm::MDString::get(VMContext, Sel.getAsString()),
1324 llvm::MDString::get(VMContext, Class->getSuperClass()->getNameAsString()),
1325 llvm::ConstantInt::get(llvm::Type::getInt1Ty(VMContext), IsClassMessage)
1327 llvm::MDNode *node = llvm::MDNode::get(VMContext, impMD);
1329 llvm::Instruction *call;
1341 llvm::Value *Receiver,
1367 // and generates an illegal instruction trap on SPARC. With LLVM it corrupts
1372 llvm::BasicBlock *startBB = 0;
1373 llvm::BasicBlock *messageBB = 0;
1374 llvm::BasicBlock *continueBB = 0;
1381 llvm::Value *isNil = Builder.CreateICmpEQ(Receiver,
1382 llvm::Constant::getNullValue(Receiver->getType()));
1387 IdTy = cast<llvm::PointerType>(CGM.getTypes().ConvertType(ASTIdTy));
1388 llvm::Value *cmd;
1396 llvm::Value *impMD[] = {
1397 llvm::MDString::get(VMContext, Sel.getAsString()),
1398 llvm::MDString::get(VMContext, Class ? Class->getNameAsString() :""),
1399 llvm::ConstantInt::get(llvm::Type::getInt1Ty(VMContext), Class!=0)
1401 llvm::MDNode *node = llvm::MDNode::get(VMContext, impMD);
1411 llvm::Value *imp;
1423 imp = CGM.CreateRuntimeFunction(llvm::FunctionType::get(IdTy, IdTy, true),
1428 imp = CGM.CreateRuntimeFunction(llvm::FunctionType::get(IdTy, IdTy, true),
1431 imp = CGM.CreateRuntimeFunction(llvm::FunctionType::get(IdTy, IdTy, true),
1441 llvm::Instruction *call;
1452 llvm::Value *v = msgRet.getScalarVal();
1453 llvm::PHINode *phi = Builder.CreatePHI(v->getType(), 2);
1455 phi->addIncoming(llvm::Constant::getNullValue(v->getType()), startBB);
1458 llvm::Value *v = msgRet.getAggregateAddr();
1459 llvm::PHINode *phi = Builder.CreatePHI(v->getType(), 2);
1460 llvm::PointerType *RetTy = cast<llvm::PointerType>(v->getType());
1461 llvm::AllocaInst *NullVal =
1464 llvm::Constant::getNullValue(RetTy->getElementType()));
1469 std::pair<llvm::Value*,llvm::Value*> v = msgRet.getComplexVal();
1470 llvm::PHINode *phi = Builder.CreatePHI(v.first->getType(), 2);
1472 phi->addIncoming(llvm::Constant::getNullValue(v.first->getType()),
1474 llvm::PHINode *phi2 = Builder.CreatePHI(v.second->getType(), 2);
1476 phi2->addIncoming(llvm::Constant::getNullValue(v.second->getType()),
1486 llvm::Constant *CGObjCGNU::
1490 ArrayRef<llvm::Constant *> MethodTypes,
1495 llvm::StructType *ObjCMethodTy = llvm::StructType::get(
1500 std::vector<llvm::Constant*> Methods;
1501 std::vector<llvm::Constant*> Elements;
1504 llvm::Constant *Method =
1509 llvm::Constant *C = MakeConstantString(MethodSels[i].getAsString());
1512 Method = llvm::ConstantExpr::getBitCast(Method,
1515 Methods.push_back(llvm::ConstantStruct::get(ObjCMethodTy, Elements));
1519 llvm::ArrayType *ObjCMethodArrayTy = llvm::ArrayType::get(ObjCMethodTy,
1521 llvm::Constant *MethodArray = llvm::ConstantArray::get(ObjCMethodArrayTy,
1525 llvm::StructType *ObjCMethodListTy = llvm::StructType::create(VMContext);
1526 llvm::Type *NextPtrTy = llvm::PointerType::getUnqual(ObjCMethodListTy);
1534 Methods.push_back(llvm::ConstantPointerNull::get(
1535 llvm::PointerType::getUnqual(ObjCMethodListTy)));
1536 Methods.push_back(llvm::ConstantInt::get(Int32Ty, MethodTypes.size()));
1544 llvm::Constant *CGObjCGNU::
1545 GenerateIvarList(ArrayRef<llvm::Constant *> IvarNames,
1546 ArrayRef<llvm::Constant *> IvarTypes,
1547 ArrayRef<llvm::Constant *> IvarOffsets) {
1551 llvm::StructType *ObjCIvarTy = llvm::StructType::get(
1556 std::vector<llvm::Constant*> Ivars;
1557 std::vector<llvm::Constant*> Elements;
1563 Ivars.push_back(llvm::ConstantStruct::get(ObjCIvarTy, Elements));
1567 llvm::ArrayType *ObjCIvarArrayTy = llvm::ArrayType::get(ObjCIvarTy,
1572 Elements.push_back(llvm::ConstantInt::get(IntTy, (int)IvarNames.size()));
1573 Elements.push_back(llvm::ConstantArray::get(ObjCIvarArrayTy, Ivars));
1575 llvm::StructType *ObjCIvarListTy = llvm::StructType::get(IntTy,
1584 llvm::Constant *CGObjCGNU::GenerateClassStructure(
1585 llvm::Constant *MetaClass,
1586 llvm::Constant *SuperClass,
1589 llvm::Constant *Version,
1590 llvm::Constant *InstanceSize,
1591 llvm::Constant *IVars,
1592 llvm::Constant *Methods,
1593 llvm::Constant *Protocols,
1594 llvm::Constant *IvarOffsets,
1595 llvm::Constant *Properties,
1596 llvm::Constant *StrongIvarBitmap,
1597 llvm::Constant *WeakIvarBitmap,
1606 llvm::StructType *ClassTy = llvm::StructType::get(
1628 llvm::Constant *Zero = llvm::ConstantInt::get(LongTy, 0);
1630 std::vector<llvm::Constant*> Elements;
1631 Elements.push_back(llvm::ConstantExpr::getBitCast(MetaClass, PtrToInt8Ty));
1635 Elements.push_back(llvm::ConstantInt::get(LongTy, info));
1637 llvm::DataLayout td(&TheModule);
1639 llvm::ConstantInt::get(LongTy,
1649 Elements.push_back(llvm::ConstantExpr::getBitCast(Protocols, PtrTy));
1651 Elements.push_back(llvm::ConstantInt::get(LongTy, 1));
1662 llvm::GlobalVariable *ClassRef = TheModule.getNamedGlobal(ClassSym);
1663 llvm::Constant *Class = MakeGlobal(ClassTy, Elements, ClassSym,
1664 llvm::GlobalValue::ExternalLinkage);
1666 ClassRef->replaceAllUsesWith(llvm::ConstantExpr::getBitCast(Class,
1674 llvm::Constant *CGObjCGNU::
1675 GenerateProtocolMethodList(ArrayRef<llvm::Constant *> MethodNames,
1676 ArrayRef<llvm::Constant *> MethodTypes) {
1678 llvm::StructType *ObjCMethodDescTy = llvm::StructType::get(
1682 std::vector<llvm::Constant*> Methods;
1683 std::vector<llvm::Constant*> Elements;
1688 Methods.push_back(llvm::ConstantStruct::get(ObjCMethodDescTy, Elements));
1690 llvm::ArrayType *ObjCMethodArrayTy = llvm::ArrayType::get(ObjCMethodDescTy,
1692 llvm::Constant *Array = llvm::ConstantArray::get(ObjCMethodArrayTy,
1694 llvm::StructType *ObjCMethodDescListTy = llvm::StructType::get(
1697 Methods.push_back(llvm::ConstantInt::get(IntTy, MethodNames.size()));
1703 llvm::Constant *CGObjCGNU::GenerateProtocolList(ArrayRef<std::string>Protocols){
1704 llvm::ArrayType *ProtocolArrayTy = llvm::ArrayType::get(PtrToInt8Ty,
1706 llvm::StructType *ProtocolListTy = llvm::StructType::get(
1711 std::vector<llvm::Constant*> Elements;
1714 llvm::Constant *protocol = 0;
1715 llvm::StringMap<llvm::Constant*>::iterator value =
1722 llvm::Constant *Ptr = llvm::ConstantExpr::getBitCast(protocol,
1726 llvm::Constant * ProtocolArray = llvm::ConstantArray::get(ProtocolArrayTy,
1730 Elements.push_back(llvm::ConstantInt::get(LongTy, Protocols.size()));
1735 llvm::Value *CGObjCGNU::GenerateProtocolRef(CodeGenFunction &CGF,
1737 llvm::Value *protocol = ExistingProtocols[PD->getNameAsString()];
1738 llvm::Type *T =
1740 return CGF.Builder.CreateBitCast(protocol, llvm::PointerType::getUnqual(T));
1743 llvm::Constant *CGObjCGNU::GenerateEmptyProtocol(
1746 SmallVector<llvm::Constant*, 0> EmptyConstantVector;
1748 llvm::Constant *ProtocolList = GenerateProtocolList(EmptyStringVector);
1749 llvm::Constant *MethodList =
1753 llvm::StructType *ProtocolTy = llvm::StructType::get(IdTy,
1761 std::vector<llvm::Constant*> Elements;
1764 Elements.push_back(llvm::ConstantExpr::getIntToPtr(
1765 llvm::ConstantInt::get(Int32Ty, ProtocolVersion), IdTy));
1787 SmallVector<llvm::Constant*, 16> InstanceMethodNames;
1788 SmallVector<llvm::Constant*, 16> InstanceMethodTypes;
1789 SmallVector<llvm::Constant*, 16> OptionalInstanceMethodNames;
1790 SmallVector<llvm::Constant*, 16> OptionalInstanceMethodTypes;
1806 SmallVector<llvm::Constant*, 16> ClassMethodNames;
1807 SmallVector<llvm::Constant*, 16> ClassMethodTypes;
1808 SmallVector<llvm::Constant*, 16> OptionalClassMethodNames;
1809 SmallVector<llvm::Constant*, 16> OptionalClassMethodTypes;
1826 llvm::Constant *ProtocolList = GenerateProtocolList(Protocols);
1827 llvm::Constant *InstanceMethodList =
1829 llvm::Constant *ClassMethodList =
1831 llvm::Constant *OptionalInstanceMethodList =
1834 llvm::Constant *OptionalClassMethodList =
1843 llvm::StructType *PropertyMetadataTy = llvm::StructType::get(
1846 std::vector<llvm::Constant*> Properties;
1847 std::vector<llvm::Constant*> OptionalProperties;
1854 std::vector<llvm::Constant*> Fields;
1863 llvm::Constant *TypeEncoding = MakeConstantString(TypeStr);
1874 llvm::Constant *TypeEncoding = MakeConstantString(TypeStr);
1883 OptionalProperties.push_back(llvm::ConstantStruct::get(PropertyMetadataTy, Fields));
1885 Properties.push_back(llvm::ConstantStruct::get(PropertyMetadataTy, Fields));
1888 llvm::Constant *PropertyArray = llvm::ConstantArray::get(
1889 llvm::ArrayType::get(PropertyMetadataTy, Properties.size()), Properties);
1890 llvm::Constant* PropertyListInitFields[] =
1891 {llvm::ConstantInt::get(IntTy, Properties.size()), NULLPtr, PropertyArray};
1893 llvm::Constant *PropertyListInit =
1894 llvm::ConstantStruct::getAnon(PropertyListInitFields);
1895 llvm::Constant *PropertyList = new llvm::GlobalVariable(TheModule,
1896 PropertyListInit->getType(), false, llvm::GlobalValue::InternalLinkage,
1899 llvm::Constant *OptionalPropertyArray =
1900 llvm::ConstantArray::get(llvm::ArrayType::get(PropertyMetadataTy,
1902 llvm::Constant* OptionalPropertyListInitFields[] = {
1903 llvm::ConstantInt::get(IntTy, OptionalProperties.size()), NULLPtr,
1906 llvm::Constant *OptionalPropertyListInit =
1907 llvm::ConstantStruct::getAnon(OptionalPropertyListInitFields);
1908 llvm::Constant *OptionalPropertyList = new llvm::GlobalVariable(TheModule,
1910 llvm::GlobalValue::InternalLinkage, OptionalPropertyListInit,
1915 llvm::StructType *ProtocolTy = llvm::StructType::get(IdTy,
1925 std::vector<llvm::Constant*> Elements;
1928 Elements.push_back(llvm::ConstantExpr::getIntToPtr(
1929 llvm::ConstantInt::get(Int32Ty, ProtocolVersion), IdTy));
1939 llvm::ConstantExpr::getBitCast(MakeGlobal(ProtocolTy, Elements,
1945 SmallVector<llvm::Constant*, 1> MethodTypes;
1947 std::vector<llvm::Constant*> Elements;
1953 Elements.push_back(llvm::ConstantExpr::getBitCast(GenerateMethodList(
1956 Elements.push_back(llvm::ConstantExpr::getBitCast(GenerateMethodList(
1959 llvm::ArrayType *ProtocolArrayTy = llvm::ArrayType::get(PtrTy,
1961 llvm::StructType *ProtocolListTy = llvm::StructType::get(
1966 std::vector<llvm::Constant*> ProtocolElements;
1967 for (llvm::StringMapIterator<llvm::Constant*> iter =
1970 llvm::Constant *Ptr = llvm::ConstantExpr::getBitCast(iter->getValue(),
1974 llvm::Constant * ProtocolArray = llvm::ConstantArray::get(ProtocolArrayTy,
1978 ProtocolElements.push_back(llvm::ConstantInt::get(LongTy,
1981 Elements.push_back(llvm::ConstantExpr::getBitCast(MakeGlobal(ProtocolListTy,
1983 Categories.push_back(llvm::ConstantExpr::getBitCast(
1984 MakeGlobal(llvm::StructType::get(PtrToInt8Ty, PtrToInt8Ty,
1999 llvm::Constant *CGObjCGNU::MakeBitField(ArrayRef<bool> bits) {
2002 (TheModule.getPointerSize() == llvm::Module::Pointer32) ? 32 : 64;
2008 return llvm::ConstantInt::get(IntPtrTy, val);
2010 SmallVector<llvm::Constant *, 8> values;
2018 values.push_back(llvm::ConstantInt::get(Int32Ty, word));
2020 llvm::ArrayType *arrayTy = llvm::ArrayType::get(Int32Ty, values.size());
2021 llvm::Constant *array = llvm::ConstantArray::get(arrayTy, values);
2022 llvm::Constant *fields[2] = {
2023 llvm::ConstantInt::get(Int32Ty, values.size()),
2025 llvm::Constant *GS = MakeGlobal(llvm::StructType::get(Int32Ty, arrayTy,
2027 llvm::Constant *ptr = llvm::ConstantExpr::getPtrToInt(GS, IntPtrTy);
2036 SmallVector<llvm::Constant*, 16> InstanceMethodTypes;
2048 SmallVector<llvm::Constant*, 16> ClassMethodTypes;
2066 std::vector<llvm::Constant*> Elements;
2070 Elements.push_back(llvm::ConstantExpr::getBitCast(GenerateMethodList(
2074 Elements.push_back(llvm::ConstantExpr::getBitCast(GenerateMethodList(
2078 Elements.push_back(llvm::ConstantExpr::getBitCast(
2080 Categories.push_back(llvm::ConstantExpr::getBitCast(
2081 MakeGlobal(llvm::StructType::get(PtrToInt8Ty, PtrToInt8Ty,
2085 llvm::Constant *CGObjCGNU::GeneratePropertyList(const ObjCImplementationDecl *OID,
2087 SmallVectorImpl<llvm::Constant*> &InstanceMethodTypes) {
2091 llvm::StructType *PropertyMetadataTy = llvm::StructType::get(
2094 std::vector<llvm::Constant*> Properties;
2101 std::vector<llvm::Constant*> Fields;
2114 llvm::Constant *TypeEncoding = MakeConstantString(TypeStr);
2128 llvm::Constant *TypeEncoding = MakeConstantString(TypeStr);
2139 Properties.push_back(llvm::ConstantStruct::get(PropertyMetadataTy, Fields));
2141 llvm::ArrayType *PropertyArrayTy =
2142 llvm::ArrayType::get(PropertyMetadataTy, Properties.size());
2143 llvm::Constant *PropertyArray = llvm::ConstantArray::get(PropertyArrayTy,
2145 llvm::Constant* PropertyListInitFields[] =
2146 {llvm::ConstantInt::get(IntTy, Properties.size()), NULLPtr, PropertyArray};
2148 llvm::Constant *PropertyListInit =
2149 llvm::ConstantStruct::getAnon(PropertyListInitFields);
2150 return new llvm::GlobalVariable(TheModule, PropertyListInit->getType(), false,
2151 llvm::GlobalValue::InternalLinkage, PropertyListInit,
2183 if (llvm::GlobalVariable *symbol =
2185 symbol->setInitializer(llvm::ConstantInt::get(LongTy, 0));
2187 new llvm::GlobalVariable(TheModule, LongTy, false,
2188 llvm::GlobalValue::ExternalLinkage, llvm::ConstantInt::get(LongTy, 0),
2197 SmallVector<llvm::Constant*, 16> IvarNames;
2198 SmallVector<llvm::Constant*, 16> IvarTypes;
2199 SmallVector<llvm::Constant*, 16> IvarOffsets;
2201 std::vector<llvm::Constant*> IvarOffsetValues;
2227 llvm::Constant *OffsetValue = llvm::ConstantInt::get(IntTy, Offset);
2231 llvm::GlobalVariable *OffsetVar = TheModule.getGlobalVariable(OffsetName);
2237 OffsetVar->setLinkage(llvm::GlobalValue::ExternalLinkage);
2239 OffsetVar = new llvm::GlobalVariable(TheModule, IntTy,
2240 false, llvm::GlobalValue::ExternalLinkage,
2261 llvm::Constant *StrongIvarBitmap = MakeBitField(StrongIvars);
2262 llvm::Constant *WeakIvarBitmap = MakeBitField(WeakIvars);
2263 llvm::GlobalVariable *IvarOffsetArray =
2269 SmallVector<llvm::Constant*, 16> InstanceMethodTypes;
2279 llvm::Constant *Properties = GeneratePropertyList(OID, InstanceMethodSels,
2285 SmallVector<llvm::Constant*, 16> ClassMethodTypes;
2304 llvm::Constant *SuperClass;
2308 SuperClass = llvm::ConstantPointerNull::get(PtrToInt8Ty);
2311 SmallVector<llvm::Constant*, 1> empty;
2313 llvm::Constant *MethodList = GenerateMethodList(ClassName, "",
2315 llvm::Constant *ClassMethodList = GenerateMethodList(ClassName, "",
2317 llvm::Constant *IvarList = GenerateIvarList(IvarNames, IvarTypes,
2329 llvm::Type *IndexTy = Int32Ty;
2330 llvm::Constant *offsetPointerIndexes[] = {Zeros[0],
2331 llvm::ConstantInt::get(IndexTy, 1), 0,
2332 llvm::ConstantInt::get(IndexTy, 2) };
2339 offsetPointerIndexes[2] = llvm::ConstantInt::get(IndexTy, ivarIndex);
2341 llvm::Constant *offsetValue = llvm::ConstantExpr::getGetElementPtr(
2344 llvm::GlobalVariable *offset = TheModule.getNamedGlobal(Name);
2350 offset->setLinkage(llvm::GlobalValue::ExternalLinkage);
2353 offset = new llvm::GlobalVariable(TheModule, offsetValue->getType(),
2354 false, llvm::GlobalValue::ExternalLinkage, offsetValue, Name);
2359 llvm::Constant *ZeroPtr = llvm::ConstantInt::get(IntPtrTy, 0);
2361 llvm::Constant *MetaClassStruct = GenerateClassStructure(NULLPtr,
2367 llvm::Constant *ClassStruct =
2370 llvm::ConstantInt::get(LongTy, instanceSize), IvarList,
2377 llvm::ConstantExpr::getBitCast(ClassStruct, IdTy));
2383 llvm::ConstantExpr::getBitCast(MetaClassStruct, IdTy));
2389 ClassStruct = llvm::ConstantExpr::getBitCast(ClassStruct, PtrToInt8Ty);
2394 llvm::Function *CGObjCGNU::ModuleInitFunction() {
2403 llvm::StructType *SelStructTy = dyn_cast<llvm::StructType>(
2405 llvm::Type *SelStructPtrTy = SelectorTy;
2407 SelStructTy = llvm::StructType::get(PtrToInt8Ty, PtrToInt8Ty, NULL);
2408 SelStructPtrTy = llvm::PointerType::getUnqual(SelStructTy);
2411 std::vector<llvm::Constant*> Elements;
2412 llvm::Constant *Statics = NULLPtr;
2415 llvm::ArrayType *StaticsArrayTy = llvm::ArrayType::get(PtrToInt8Ty,
2425 Elements.push_back(llvm::ConstantArray::get(StaticsArrayTy,
2427 llvm::StructType *StaticsListTy =
2428 llvm::StructType::get(PtrToInt8Ty, StaticsArrayTy, NULL);
2429 llvm::Type *StaticsListPtrTy =
2430 llvm::PointerType::getUnqual(StaticsListTy);
2432 llvm::ArrayType *StaticsListArrayTy =
2433 llvm::ArrayType::get(StaticsListPtrTy, 2);
2436 Elements.push_back(llvm::Constant::getNullValue(StaticsListPtrTy));
2438 Statics = llvm::ConstantExpr::getBitCast(Statics, PtrTy);
2441 llvm::ArrayType *ClassListTy = llvm::ArrayType::get(PtrToInt8Ty,
2443 llvm::StructType *SymTabTy = llvm::StructType::get(LongTy, SelStructPtrTy,
2444 llvm::Type::getInt16Ty(VMContext),
2445 llvm::Type::getInt16Ty(VMContext),
2450 std::vector<llvm::Constant*> Selectors;
2451 std::vector<llvm::GlobalAlias*> SelectorAliases;
2456 llvm::Constant *SelName = ExportUniqueString(SelNameStr, ".objc_sel_name");
2462 llvm::Constant *SelectorTypeEncoding = NULLPtr;
2468 Selectors.push_back(llvm::ConstantStruct::get(SelStructTy, Elements));
2482 Selectors.push_back(llvm::ConstantStruct::get(SelStructTy, Elements));
2486 Elements.push_back(llvm::ConstantInt::get(LongTy, SelectorCount));
2487 llvm::Constant *SelectorList = MakeGlobalArray(SelStructTy, Selectors,
2489 Elements.push_back(llvm::ConstantExpr::getBitCast(SelectorList,
2495 llvm::Constant *Idxs[] = {Zeros[0],
2496 llvm::ConstantInt::get(Int32Ty, i), Zeros[0]};
2498 llvm::Constant *SelPtr = llvm::ConstantExpr::getGetElementPtr(SelectorList,
2502 SelPtr = llvm::ConstantExpr::getBitCast(SelPtr, SelectorTy);
2508 Elements.push_back(llvm::ConstantInt::get(llvm::Type::getInt16Ty(VMContext),
2511 Elements.push_back(llvm::ConstantInt::get(llvm::Type::getInt16Ty(VMContext),
2518 llvm::Constant *ClassList = llvm::ConstantArray::get(ClassListTy, Classes);
2521 llvm::Constant *SymTab= MakeGlobal(SymTabTy, Elements);
2525 llvm::StructType * ModuleTy = llvm::StructType::get(LongTy, LongTy,
2526 PtrToInt8Ty, llvm::PointerType::getUnqual(SymTabTy),
2530 Elements.push_back(llvm::ConstantInt::get(LongTy, RuntimeVersion));
2532 llvm::DataLayout td(&TheModule);
2534 llvm::ConstantInt::get(LongTy,
2549 Elements.push_back(llvm::ConstantInt::get(IntTy, 2));
2553 Elements.push_back(llvm::ConstantInt::get(IntTy, 1));
2555 Elements.push_back(llvm::ConstantInt::get(IntTy, 0));
2558 Elements.push_back(llvm::ConstantInt::get(IntTy, 1));
2562 llvm::Value *Module = MakeGlobal(ModuleTy, Elements);
2566 llvm::Function * LoadFunction = llvm::Function::Create(
2567 llvm::FunctionType::get(llvm::Type::getVoidTy(VMContext), false),
2568 llvm::GlobalValue::InternalLinkage, ".objc_load_function",
2570 llvm::BasicBlock *EntryBB =
2571 llvm::BasicBlock::Create(VMContext, "entry", LoadFunction);
2575 llvm::FunctionType *FT =
2576 llvm::FunctionType::get(Builder.getVoidTy(),
2577 llvm::PointerType::getUnqual(ModuleTy), true);
2578 llvm::Value *Register = CGM.CreateRuntimeFunction(FT, "__objc_exec_class");
2582 llvm::Type *ArgTypes[2] = {PtrTy, PtrToInt8Ty};
2583 llvm::FunctionType *RegisterAliasTy =
2584 llvm::FunctionType::get(Builder.getVoidTy(),
2586 llvm::Function *RegisterAlias = llvm::Function::Create(
2588 llvm::GlobalValue::ExternalWeakLinkage, "class_registerAlias_np",
2590 llvm::BasicBlock *AliasBB =
2591 llvm::BasicBlock::Create(VMContext, "alias", LoadFunction);
2592 llvm::BasicBlock *NoAliasBB =
2593 llvm::BasicBlock::Create(VMContext, "no_alias", LoadFunction);
2596 llvm::Value *HasRegisterAlias = Builder.CreateICmpNE(RegisterAlias,
2597 llvm::Constant::getNullValue(RegisterAlias->getType()));
2605 llvm::Constant *TheClass =
2609 TheClass = llvm
2625 llvm::Function *CGObjCGNU::GenerateMethod(const ObjCMethodDecl *OMD,
2635 llvm::FunctionType *MethodTy =
2640 llvm::Function *Method
2641 = llvm::Function::Create(MethodTy,
2642 llvm::GlobalValue::InternalLinkage,
2648 llvm::Constant *CGObjCGNU::GetPropertyGetFunction() {
2652 llvm::Constant *CGObjCGNU::GetPropertySetFunction() {
2656 llvm::Constant *CGObjCGNU::GetOptimizedPropertySetFunction(bool atomic,
2661 llvm::Constant *CGObjCGNU::GetGetStructFunction() {
2664 llvm::Constant *CGObjCGNU::GetSetStructFunction() {
2667 llvm::Constant *CGObjCGNU::GetCppAtomicObjectGetFunction() {
2670 llvm::Constant *CGObjCGNU::GetCppAtomicObjectSetFunction() {
2674 llvm::Constant *CGObjCGNU::EnumerationMutationFunction() {
2704 llvm::Value *ExceptionAsObject;
2707 llvm::Value *Exception = CGF.EmitObjCThrowOperand(ThrowExpr);
2715 llvm::CallSite Throw =
2723 llvm::Value * CGObjCGNU::EmitObjCWeakRead(CodeGenFunction &CGF,
2724 llvm::Value *AddrWeakObj) {
2731 llvm::Value *src, llvm::Value *dst) {
2739 llvm::Value *src, llvm::Value *dst,
2752 llvm::Value *src, llvm::Value *dst,
2753 llvm::Value *ivarOffset) {
2761 llvm::Value *src, llvm::Value *dst) {
2769 llvm::Value *DestPtr,
2770 llvm::Value *SrcPtr,
2771 llvm::Value *Size) {
2779 llvm::GlobalVariable *CGObjCGNU::ObjCIvarOffsetVariable(
2787 llvm::GlobalVariable *IvarOffsetPointer = TheModule.getNamedGlobal(Name);
2803 llvm::ConstantInt *OffsetGuess = llvm::ConstantInt::get(Int32Ty, Offset,
2810 llvm::GlobalVariable *IvarOffsetGV = new llvm::GlobalVariable(TheModule,
2812 llvm::GlobalValue::PrivateLinkage, OffsetGuess, Name+".guess");
2813 IvarOffsetPointer = new llvm::GlobalVariable(TheModule,
2814 IvarOffsetGV->getType(), false, llvm::GlobalValue::LinkOnceAnyLinkage,
2817 IvarOffsetPointer = new llvm::GlobalVariable(TheModule,
2818 llvm::Type::getInt32PtrTy(VMContext), false,
2819 llvm::GlobalValue::ExternalLinkage, 0, Name);
2827 llvm::Value *BaseValue,
2852 llvm::Value *CGObjCGNU::EmitIvarOffset(CodeGenFunction &CGF,
2864 llvm::Value *Offset = TheModule.getGlobalVariable(name);
2866 Offset = new llvm::GlobalVariable(TheModule, IntTy,
2867 false, llvm::GlobalValue::LinkOnceAnyLinkage,
2868 llvm::Constant::getNullValue(IntTy), name);
2875 return llvm::ConstantInt::get(PtrDiffTy, Offset, /*isSigned*/true);