diff options
author | Alexander Kornienko <alexfh@google.com> | 2023-09-01 11:06:48 +0200 |
---|---|---|
committer | Alexander Kornienko <alexfh@google.com> | 2023-09-01 12:53:24 +0200 |
commit | b7f4915644844fb9f32e8763922a070f5fe4fd29 (patch) | |
tree | f7d85f559e082bc939611cf0d221676bdbf365c6 /clang/lib | |
parent | 1148cfac51f28438b3684976cb14cde73935ea7f (diff) | |
download | llvm-b7f4915644844fb9f32e8763922a070f5fe4fd29.zip llvm-b7f4915644844fb9f32e8763922a070f5fe4fd29.tar.gz llvm-b7f4915644844fb9f32e8763922a070f5fe4fd29.tar.bz2 |
Revert "Reapply: [IRGen] Emit lifetime intrinsics around temporary aggregate argument allocas"
This reverts commit e698695fbbf62e6676f8907665187f2d2c4d814b. The commit caused
invalid AddressSanitizer: stack-use-after-scope errors.
See https://reviews.llvm.org/D74094#4633785 for details.
Differential Revision: https://reviews.llvm.org/D159346
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/CodeGen/CGCall.cpp | 23 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGCall.h | 20 |
2 files changed, 1 insertions, 42 deletions
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index af05eec..37ccd0d 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -40,7 +40,6 @@ #include "llvm/IR/IntrinsicInst.h" #include "llvm/IR/Intrinsics.h" #include "llvm/IR/Type.h" -#include "llvm/Support/TypeSize.h" #include "llvm/Transforms/Utils/Local.h" #include <optional> using namespace clang; @@ -4616,24 +4615,7 @@ void CodeGenFunction::EmitCallArg(CallArgList &args, const Expr *E, return; } - AggValueSlot ArgSlot = AggValueSlot::ignored(); - if (hasAggregateEvaluationKind(E->getType())) { - Address ArgSlotAlloca = Address::invalid(); - ArgSlot = CreateAggTemp(E->getType(), "agg.tmp", &ArgSlotAlloca); - - // Emit a lifetime start/end for this temporary. If the type has a - // destructor, then we need to keep it alive. FIXME: We should still be able - // to end the lifetime after the destructor returns. - if (!E->getType().isDestructedType()) { - llvm::TypeSize size = - CGM.getDataLayout().getTypeAllocSize(ConvertTypeForMem(E->getType())); - if (llvm::Value *lifetimeSize = - EmitLifetimeStart(size, ArgSlotAlloca.getPointer())) - args.addLifetimeCleanup({ArgSlotAlloca.getPointer(), lifetimeSize}); - } - } - - args.add(EmitAnyExpr(E, ArgSlot), type); + args.add(EmitAnyExprToTemp(E), type); } QualType CodeGenFunction::getVarArgType(const Expr *Arg) { @@ -5822,9 +5804,6 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo, for (CallLifetimeEnd &LifetimeEnd : CallLifetimeEndAfterCall) LifetimeEnd.Emit(*this, /*Flags=*/{}); - for (const CallArgList::EndLifetimeInfo < : CallArgs.getLifetimeCleanups()) - EmitLifetimeEnd(LT.Size, LT.Addr); - if (!ReturnValue.isExternallyDestructed() && RetTy.isDestructedType() == QualType::DK_nontrivial_c_struct) pushDestroy(QualType::DK_nontrivial_c_struct, Ret.getAggregateAddress(), diff --git a/clang/lib/CodeGen/CGCall.h b/clang/lib/CodeGen/CGCall.h index cc0b1da..aee86a3 100644 --- a/clang/lib/CodeGen/CGCall.h +++ b/clang/lib/CodeGen/CGCall.h @@ -278,11 +278,6 @@ public: llvm::Instruction *IsActiveIP; }; - struct EndLifetimeInfo { - llvm::Value *Addr; - llvm::Value *Size; - }; - void add(RValue rvalue, QualType type) { push_back(CallArg(rvalue, type)); } void addUncopiedAggregate(LValue LV, QualType type) { @@ -299,9 +294,6 @@ public: CleanupsToDeactivate.insert(CleanupsToDeactivate.end(), other.CleanupsToDeactivate.begin(), other.CleanupsToDeactivate.end()); - LifetimeCleanups.insert(LifetimeCleanups.end(), - other.LifetimeCleanups.begin(), - other.LifetimeCleanups.end()); assert(!(StackBase && other.StackBase) && "can't merge stackbases"); if (!StackBase) StackBase = other.StackBase; @@ -341,14 +333,6 @@ public: /// memory. bool isUsingInAlloca() const { return StackBase; } - void addLifetimeCleanup(EndLifetimeInfo Info) { - LifetimeCleanups.push_back(Info); - } - - ArrayRef<EndLifetimeInfo> getLifetimeCleanups() const { - return LifetimeCleanups; - } - private: SmallVector<Writeback, 1> Writebacks; @@ -357,10 +341,6 @@ private: /// occurs. SmallVector<CallArgCleanup, 1> CleanupsToDeactivate; - /// Lifetime information needed to call llvm.lifetime.end for any temporary - /// argument allocas. - SmallVector<EndLifetimeInfo, 2> LifetimeCleanups; - /// The stacksave call. It dominates all of the argument evaluation. llvm::CallInst *StackBase = nullptr; }; |