diff options
| author | David Chisnall <csdavec@swan.ac.uk> | 2011-10-08 08:54:36 +0000 |
|---|---|---|
| committer | David Chisnall <csdavec@swan.ac.uk> | 2011-10-08 08:54:36 +0000 |
| commit | e0dc7cb2e258b2fb6fc935a275e2708540f0c83b (patch) | |
| tree | 305d2ab6993cf07f038115823263f3cea038ff36 | |
| parent | e45373520d747d5cce03c088b135beff74df4626 (diff) | |
| download | bcm5719-llvm-e0dc7cb2e258b2fb6fc935a275e2708540f0c83b.tar.gz bcm5719-llvm-e0dc7cb2e258b2fb6fc935a275e2708540f0c83b.zip | |
Apparently getPtrToInt() takes an explicit type parameter to allow you to generate invalid bitcode, not so that it can actually produce a value of this type. This should fix PR11085.
llvm-svn: 141482
| -rw-r--r-- | clang/lib/CodeGen/CGObjCGNU.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp index 59a1d753ad6..d3da649fbbf 100644 --- a/clang/lib/CodeGen/CGObjCGNU.cpp +++ b/clang/lib/CodeGen/CGObjCGNU.cpp @@ -153,6 +153,8 @@ protected: llvm::IntegerType *LongTy; /// LLVM type for C size_t. Used in various runtime data structures. llvm::IntegerType *SizeTy; + /// LLVM type for C intptr_t. + llvm::IntegerType *IntPtrTy; /// LLVM type for C ptrdiff_t. Mainly used in property accessor functions. llvm::IntegerType *PtrDiffTy; /// LLVM type for C int*. Used for GCC-ABI-compatible non-fragile instance @@ -717,6 +719,9 @@ CGObjCGNU::CGObjCGNU(CodeGenModule &cgm, unsigned runtimeABIVersion, Int32Ty = llvm::Type::getInt32Ty(VMContext); Int64Ty = llvm::Type::getInt64Ty(VMContext); + IntPtrTy = + TheModule.getPointerSize() == llvm::Module::Pointer32 ? Int32Ty : Int64Ty; + // Object type QualType UnqualIdTy = CGM.getContext().getObjCIdType(); ASTIdTy = CanQualType(); @@ -1742,7 +1747,10 @@ llvm::Constant *CGObjCGNU::MakeBitField(llvm::SmallVectorImpl<bool> &bits) { array }; llvm::Constant *GS = MakeGlobal(llvm::StructType::get(Int32Ty, arrayTy, NULL), fields); - return llvm::ConstantExpr::getPtrToInt(GS, Int64Ty); + llvm::Constant *ptr = llvm::ConstantExpr::getPtrToInt(GS, IntPtrTy); + if (IntPtrTy != Int64Ty) + ptr = llvm::ConstantExpr::getZExt(ptr, Int64Ty); + return ptr; } void CGObjCGNU::GenerateCategory(const ObjCCategoryImplDecl *OCD) { @@ -2471,8 +2479,7 @@ llvm::GlobalVariable *CGObjCGNU::ObjCIvarOffsetVariable( const_cast<ObjCInterfaceDecl *>(ID))) Offset = ComputeIvarBaseOffset(CGM, ID, Ivar); - llvm::ConstantInt *OffsetGuess = - llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext), Offset, + llvm::ConstantInt *OffsetGuess = llvm::ConstantInt::get(Int32Ty, Offset, /*isSigned*/true); // Don't emit the guess in non-PIC code because the linker will not be able // to replace it with the real version for a library. In non-PIC code you |

