Skip to content

Commit e26c24b

Browse files
committed
Revert "[IRGen] Emit lifetime intrinsics around temporary aggregate argument allocas"
This reverts commit fafc6e4. Should fix ppc stage2 failure: http://lab.llvm.org:8011/builders/clang-ppc64be-linux-multistage/builds/23546 Conflicts: clang/lib/CodeGen/CGCall.cpp
1 parent bfaf535 commit e26c24b

File tree

5 files changed

+1
-152
lines changed

5 files changed

+1
-152
lines changed

clang/lib/CodeGen/CGCall.cpp

+1-21
Original file line numberDiff line numberDiff line change
@@ -3692,24 +3692,7 @@ void CodeGenFunction::EmitCallArg(CallArgList &args, const Expr *E,
36923692
return;
36933693
}
36943694

3695-
AggValueSlot ArgSlot = AggValueSlot::ignored();
3696-
Address ArgSlotAlloca = Address::invalid();
3697-
if (hasAggregateEvaluationKind(E->getType())) {
3698-
ArgSlot = CreateAggTemp(E->getType(), "agg.tmp", &ArgSlotAlloca);
3699-
3700-
// Emit a lifetime start/end for this temporary. If the type has a
3701-
// destructor, then we need to keep it alive. FIXME: We should still be able
3702-
// to end the lifetime after the destructor returns.
3703-
if (!E->getType().isDestructedType()) {
3704-
uint64_t size =
3705-
CGM.getDataLayout().getTypeAllocSize(ConvertTypeForMem(E->getType()));
3706-
if (auto *lifetimeSize =
3707-
EmitLifetimeStart(size, ArgSlotAlloca.getPointer()))
3708-
args.addLifetimeCleanup({ArgSlotAlloca.getPointer(), lifetimeSize});
3709-
}
3710-
}
3711-
3712-
args.add(EmitAnyExpr(E, ArgSlot), type);
3695+
args.add(EmitAnyExprToTemp(E), type);
37133696
}
37143697

37153698
QualType CodeGenFunction::getVarArgType(const Expr *Arg) {
@@ -4810,9 +4793,6 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
48104793
for (CallLifetimeEnd &LifetimeEnd : CallLifetimeEndAfterCall)
48114794
LifetimeEnd.Emit(*this, /*Flags=*/{});
48124795

4813-
for (auto &LT : CallArgs.getLifetimeCleanups())
4814-
EmitLifetimeEnd(LT.Size, LT.Addr);
4815-
48164796
return Ret;
48174797
}
48184798

clang/lib/CodeGen/CGCall.h

-20
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,6 @@ class CallArgList : public SmallVector<CallArg, 8> {
283283
llvm::Instruction *IsActiveIP;
284284
};
285285

286-
struct EndLifetimeInfo {
287-
llvm::Value *Addr;
288-
llvm::Value *Size;
289-
};
290-
291286
void add(RValue rvalue, QualType type) { push_back(CallArg(rvalue, type)); }
292287

293288
void addUncopiedAggregate(LValue LV, QualType type) {
@@ -304,9 +299,6 @@ class CallArgList : public SmallVector<CallArg, 8> {
304299
CleanupsToDeactivate.insert(CleanupsToDeactivate.end(),
305300
other.CleanupsToDeactivate.begin(),
306301
other.CleanupsToDeactivate.end());
307-
LifetimeCleanups.insert(LifetimeCleanups.end(),
308-
other.LifetimeCleanups.begin(),
309-
other.LifetimeCleanups.end());
310302
assert(!(StackBase && other.StackBase) && "can't merge stackbases");
311303
if (!StackBase)
312304
StackBase = other.StackBase;
@@ -346,14 +338,6 @@ class CallArgList : public SmallVector<CallArg, 8> {
346338
/// memory.
347339
bool isUsingInAlloca() const { return StackBase; }
348340

349-
void addLifetimeCleanup(EndLifetimeInfo Info) {
350-
LifetimeCleanups.push_back(Info);
351-
}
352-
353-
ArrayRef<EndLifetimeInfo> getLifetimeCleanups() const {
354-
return LifetimeCleanups;
355-
}
356-
357341
private:
358342
SmallVector<Writeback, 1> Writebacks;
359343

@@ -362,10 +346,6 @@ class CallArgList : public SmallVector<CallArg, 8> {
362346
/// occurs.
363347
SmallVector<CallArgCleanup, 1> CleanupsToDeactivate;
364348

365-
/// Lifetime information needed to call llvm.lifetime.end for any temporary
366-
/// argument allocas.
367-
SmallVector<EndLifetimeInfo, 2> LifetimeCleanups;
368-
369349
/// The stacksave call. It dominates all of the argument evaluation.
370350
llvm::CallInst *StackBase;
371351
};

clang/test/CodeGen/lifetime-call-temp.c

-83
This file was deleted.

clang/test/CodeGenCXX/amdgcn-call-with-aggarg.cpp

-19
This file was deleted.

clang/test/CodeGenCXX/stack-reuse-miscompile.cpp

-9
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ const char * f(S s)
2626
// CHECK: [[T2:%.*]] = alloca %class.T, align 4
2727
// CHECK: [[T3:%.*]] = alloca %class.T, align 4
2828
//
29-
// CHECK: [[AGG:%.*]] = alloca %class.S, align 4
30-
//
3129
// FIXME: We could defer starting the lifetime of the return object of concat
3230
// until the call.
3331
// CHECK: [[T1i8:%.*]] = bitcast %class.T* [[T1]] to i8*
@@ -39,15 +37,8 @@ const char * f(S s)
3937
//
4038
// CHECK: [[T3i8:%.*]] = bitcast %class.T* [[T3]] to i8*
4139
// CHECK: call void @llvm.lifetime.start.p0i8(i64 16, i8* [[T3i8]])
42-
//
43-
// CHECK: [[AGGi8:%.*]] = bitcast %class.S* [[AGG]] to i8*
44-
// CHECK: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[AGGi8]])
45-
//
4640
// CHECK: [[T5:%.*]] = call %class.T* @_ZN1TC1E1S(%class.T* [[T3]], [2 x i32] %{{.*}})
4741
//
48-
// CHECK: [[AGGi8:%.*]] = bitcast %class.S* {{.*}} to i8*
49-
// CHECK: call void @llvm.lifetime.end.p0i8(i64 8, i8* [[AGGi8]])
50-
//
5142
// CHECK: call void @_ZNK1T6concatERKS_(%class.T* sret [[T1]], %class.T* [[T2]], %class.T* dereferenceable(16) [[T3]])
5243
// CHECK: [[T6:%.*]] = call i8* @_ZNK1T3strEv(%class.T* [[T1]])
5344
//

0 commit comments

Comments
 (0)