diff options
author | Hsiangkai Wang <kai.wang@sifive.com> | 2021-05-20 10:22:08 +0800 |
---|---|---|
committer | Hsiangkai Wang <kai.wang@sifive.com> | 2021-06-07 23:30:13 +0800 |
commit | 2b13ff69794680ea0764e516f5b69b80219771b7 (patch) | |
tree | e54b5c3f83f102cc4047b8d3f4e625b58d7eeb12 /clang/lib/CodeGen/CGDecl.cpp | |
parent | cfcdebaf323575952ef8326c32e47d351b79ee37 (diff) | |
download | llvm-2b13ff69794680ea0764e516f5b69b80219771b7.zip llvm-2b13ff69794680ea0764e516f5b69b80219771b7.tar.gz llvm-2b13ff69794680ea0764e516f5b69b80219771b7.tar.bz2 |
[Clang][CodeGen] Set the size of llvm.lifetime to unknown for scalable types.
If the memory object is scalable type, we do not know the exact size of
it at compile time. Set the size of lifetime marker to unknown if the
object is scalable one.
Differential Revision: https://reviews.llvm.org/D102822
Diffstat (limited to 'clang/lib/CodeGen/CGDecl.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGDecl.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index 3be0f6a..7948f43 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -1318,7 +1318,7 @@ void CodeGenFunction::EmitAutoVarDecl(const VarDecl &D) { /// Emit a lifetime.begin marker if some criteria are satisfied. /// \return a pointer to the temporary size Value if a marker was emitted, null /// otherwise -llvm::Value *CodeGenFunction::EmitLifetimeStart(uint64_t Size, +llvm::Value *CodeGenFunction::EmitLifetimeStart(llvm::TypeSize Size, llvm::Value *Addr) { if (!ShouldEmitLifetimeMarkers) return nullptr; @@ -1326,7 +1326,8 @@ llvm::Value *CodeGenFunction::EmitLifetimeStart(uint64_t Size, assert(Addr->getType()->getPointerAddressSpace() == CGM.getDataLayout().getAllocaAddrSpace() && "Pointer should be in alloca address space"); - llvm::Value *SizeV = llvm::ConstantInt::get(Int64Ty, Size); + llvm::Value *SizeV = llvm::ConstantInt::get( + Int64Ty, Size.isScalable() ? -1 : Size.getFixedValue()); Addr = Builder.CreateBitCast(Addr, AllocaInt8PtrTy); llvm::CallInst *C = Builder.CreateCall(CGM.getLLVMLifetimeStartFn(), {SizeV, Addr}); @@ -1549,12 +1550,9 @@ CodeGenFunction::EmitAutoVarAlloca(const VarDecl &D) { // is rare. if (!Bypasses.IsBypassed(&D) && !(!getLangOpts().CPlusPlus && hasLabelBeenSeenInCurrentScope())) { - llvm::TypeSize size = - CGM.getDataLayout().getTypeAllocSize(allocaTy); + llvm::TypeSize Size = CGM.getDataLayout().getTypeAllocSize(allocaTy); emission.SizeForLifetimeMarkers = - size.isScalable() ? EmitLifetimeStart(-1, AllocaAddr.getPointer()) - : EmitLifetimeStart(size.getFixedSize(), - AllocaAddr.getPointer()); + EmitLifetimeStart(Size, AllocaAddr.getPointer()); } } else { assert(!emission.useLifetimeMarkers()); |