diff options
| author | Yaxun Liu <Yaxun.Liu@amd.com> | 2017-06-29 18:47:45 +0000 |
|---|---|---|
| committer | Yaxun Liu <Yaxun.Liu@amd.com> | 2017-06-29 18:47:45 +0000 |
| commit | e9e5c4f975223de3c368773b77e16f476ede9ac2 (patch) | |
| tree | c2d6b4093ada2d213c7cfa8d4dd1804eb333b05b /clang/lib/CodeGen | |
| parent | d3a05713012f33bd36670ea104788822d24e971d (diff) | |
| download | bcm5719-llvm-e9e5c4f975223de3c368773b77e16f476ede9ac2.tar.gz bcm5719-llvm-e9e5c4f975223de3c368773b77e16f476ede9ac2.zip | |
CodeGen: Fix invalid bitcast for coerced function argument
Clang assumes coerced function argument is in address space 0, which is not always true and results in invalid bitcasts.
This patch fixes failure in OpenCL conformance test api/get_kernel_arg_info with amdgcn---amdgizcl triple, where non-zero alloca address space is used.
Differential Revision: https://reviews.llvm.org/D34777
llvm-svn: 306721
Diffstat (limited to 'clang/lib/CodeGen')
| -rw-r--r-- | clang/lib/CodeGen/CGCall.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index 8795e4a8998..13a156c7bbd 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -1297,7 +1297,7 @@ static void CreateCoercedStore(llvm::Value *Src, // If store is legal, just bitcast the src pointer. if (SrcSize <= DstSize) { - Dst = CGF.Builder.CreateBitCast(Dst, llvm::PointerType::getUnqual(SrcTy)); + Dst = CGF.Builder.CreateElementBitCast(Dst, SrcTy); BuildAggStore(CGF, Src, Dst, DstIsVolatile); } else { // Otherwise do coercion through memory. This is stupid, but @@ -2412,8 +2412,7 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI, Address AddrToStoreInto = Address::invalid(); if (SrcSize <= DstSize) { - AddrToStoreInto = - Builder.CreateBitCast(Ptr, llvm::PointerType::getUnqual(STy)); + AddrToStoreInto = Builder.CreateElementBitCast(Ptr, STy); } else { AddrToStoreInto = CreateTempAlloca(STy, Alloca.getAlignment(), "coerce"); |

