diff options
author | Dylan McKay <me@dylanmckay.io> | 2018-11-09 17:15:06 +0000 |
---|---|---|
committer | Dylan McKay <me@dylanmckay.io> | 2018-11-09 17:15:06 +0000 |
commit | 21e7f5e24eb1fef1676d70eb013b1346482a7bac (patch) | |
tree | d92b3014d66dbe420eef3d71041252365f81e45c /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | 96d37cf5374761e0f07f1ad064798e92d04786d8 (diff) | |
download | bcm5719-llvm-21e7f5e24eb1fef1676d70eb013b1346482a7bac.tar.gz bcm5719-llvm-21e7f5e24eb1fef1676d70eb013b1346482a7bac.zip |
Use the correct address space when emitting the ctor function list
This patch modifies clang so that, if compiling for a target that
explicitly specifies a nonzero program memory address space, the
constructor list global will have the same address space as the
functions it contains.
AVR is the only in-tree backend which has a nonzero program memory
address space.
Without this, the IR verifier would always fail if a constructor
was used on a Harvard architecture backend.
This has no functional change to any in-tree backends except AVR.
llvm-svn: 346520
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index f55fa3f1bcb..d62d8be195d 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -1105,11 +1105,12 @@ void CodeGenModule::EmitCtorList(CtorList &Fns, const char *GlobalName) { // Ctor function type is void()*. llvm::FunctionType* CtorFTy = llvm::FunctionType::get(VoidTy, false); - llvm::Type *CtorPFTy = llvm::PointerType::getUnqual(CtorFTy); + llvm::Type *CtorPFTy = llvm::PointerType::get(CtorFTy, + TheModule.getDataLayout().getProgramAddressSpace()); // Get the type of a ctor entry, { i32, void ()*, i8* }. llvm::StructType *CtorStructTy = llvm::StructType::get( - Int32Ty, llvm::PointerType::getUnqual(CtorFTy), VoidPtrTy); + Int32Ty, CtorPFTy, VoidPtrTy); // Construct the constructor and destructor arrays. ConstantInitBuilder builder(*this); |