diff options
author | Matt Arsenault <Matthew.Arsenault@amd.com> | 2014-04-17 17:45:37 +0000 |
---|---|---|
committer | Matt Arsenault <Matthew.Arsenault@amd.com> | 2014-04-17 17:45:37 +0000 |
commit | 10e3ef8d2df8e578d620518ee36febe5c236523a (patch) | |
tree | d079217fadc73b72cd629fb50f29635456975325 /clang/lib/CodeGen/CGExprConstant.cpp | |
parent | da1c510ea6116060bccfde5728cdb9fb137a2c36 (diff) | |
download | bcm5719-llvm-10e3ef8d2df8e578d620518ee36febe5c236523a.tar.gz bcm5719-llvm-10e3ef8d2df8e578d620518ee36febe5c236523a.zip |
Bug 18567: Fix constantexpr pointer casts with address spaces.
Getting a pointer into a struct at a non-zero offset would try to
use the default address space.
llvm-svn: 206478
Diffstat (limited to 'clang/lib/CodeGen/CGExprConstant.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGExprConstant.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp index 82382ddf688..bce0475cbc0 100644 --- a/clang/lib/CodeGen/CGExprConstant.cpp +++ b/clang/lib/CodeGen/CGExprConstant.cpp @@ -1063,7 +1063,9 @@ llvm::Constant *CodeGenModule::EmitConstantValue(const APValue &Value, // Apply offset if necessary. if (!Offset->isNullValue()) { - llvm::Constant *Casted = llvm::ConstantExpr::getBitCast(C, Int8PtrTy); + unsigned AS = C->getType()->getPointerAddressSpace(); + llvm::Type *CharPtrTy = Int8Ty->getPointerTo(AS); + llvm::Constant *Casted = llvm::ConstantExpr::getBitCast(C, CharPtrTy); Casted = llvm::ConstantExpr::getGetElementPtr(Casted, Offset); C = llvm::ConstantExpr::getPointerCast(Casted, C->getType()); } |