diff options
| author | Yaxun Liu <Yaxun.Liu@amd.com> | 2018-05-17 11:16:35 +0000 |
|---|---|---|
| committer | Yaxun Liu <Yaxun.Liu@amd.com> | 2018-05-17 11:16:35 +0000 |
| commit | a2a9cfab83a9252b3fbdb0b487fd5acb6e32b323 (patch) | |
| tree | 30e72c76769d7131b0a4ed072e57a6552433910e /clang/lib/CodeGen/CGExprAgg.cpp | |
| parent | 0e69e2d74739a119a78d131c29b92c25787ec2f3 (diff) | |
| download | bcm5719-llvm-a2a9cfab83a9252b3fbdb0b487fd5acb6e32b323.tar.gz bcm5719-llvm-a2a9cfab83a9252b3fbdb0b487fd5acb6e32b323.zip | |
CodeGen: Fix invalid bitcast for lifetime.start/end
lifetime.start/end expects pointer argument in alloca address space.
However in C++ a temporary variable is in default address space.
This patch changes API CreateMemTemp and CreateTempAlloca to
get the original alloca instruction and pass it lifetime.start/end.
It only affects targets with non-zero alloca address space.
Differential Revision: https://reviews.llvm.org/D45900
llvm-svn: 332593
Diffstat (limited to 'clang/lib/CodeGen/CGExprAgg.cpp')
| -rw-r--r-- | clang/lib/CodeGen/CGExprAgg.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp index 713224ca12d..41e32a9d60f 100644 --- a/clang/lib/CodeGen/CGExprAgg.cpp +++ b/clang/lib/CodeGen/CGExprAgg.cpp @@ -253,6 +253,7 @@ void AggExprEmitter::withReturnValueSlot( (RequiresDestruction && !Dest.getAddress().isValid()); Address RetAddr = Address::invalid(); + Address RetAllocaAddr = Address::invalid(); EHScopeStack::stable_iterator LifetimeEndBlock; llvm::Value *LifetimeSizePtr = nullptr; @@ -260,10 +261,10 @@ void AggExprEmitter::withReturnValueSlot( if (!UseTemp) { RetAddr = Dest.getAddress(); } else { - RetAddr = CGF.CreateMemTemp(RetTy); + RetAddr = CGF.CreateMemTemp(RetTy, "tmp", &RetAllocaAddr); uint64_t Size = CGF.CGM.getDataLayout().getTypeAllocSize(CGF.ConvertTypeForMem(RetTy)); - LifetimeSizePtr = CGF.EmitLifetimeStart(Size, RetAddr.getPointer()); + LifetimeSizePtr = CGF.EmitLifetimeStart(Size, RetAllocaAddr.getPointer()); if (LifetimeSizePtr) { LifetimeStartInst = cast<llvm::IntrinsicInst>(std::prev(Builder.GetInsertPoint())); @@ -272,7 +273,7 @@ void AggExprEmitter::withReturnValueSlot( "Last insertion wasn't a lifetime.start?"); CGF.pushFullExprCleanup<CodeGenFunction::CallLifetimeEnd>( - NormalEHLifetimeMarker, RetAddr, LifetimeSizePtr); + NormalEHLifetimeMarker, RetAllocaAddr, LifetimeSizePtr); LifetimeEndBlock = CGF.EHStack.stable_begin(); } } @@ -294,7 +295,7 @@ void AggExprEmitter::withReturnValueSlot( // Since we're not guaranteed to be in an ExprWithCleanups, clean up // eagerly. CGF.DeactivateCleanupBlock(LifetimeEndBlock, LifetimeStartInst); - CGF.EmitLifetimeEnd(LifetimeSizePtr, RetAddr.getPointer()); + CGF.EmitLifetimeEnd(LifetimeSizePtr, RetAllocaAddr.getPointer()); } } |

