Skip to content

Commit

Permalink
Revert "[IRGen] Emit lifetime intrinsics around temporary aggregate a…
Browse files Browse the repository at this point in the history
…rgument 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
  • Loading branch information
epilk committed Feb 12, 2020
1 parent bfaf535 commit e26c24b
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 152 deletions.
22 changes: 1 addition & 21 deletions clang/lib/CodeGen/CGCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3692,24 +3692,7 @@ void CodeGenFunction::EmitCallArg(CallArgList &args, const Expr *E,
return;
}

AggValueSlot ArgSlot = AggValueSlot::ignored();
Address ArgSlotAlloca = Address::invalid();
if (hasAggregateEvaluationKind(E->getType())) {
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()) {
uint64_t size =
CGM.getDataLayout().getTypeAllocSize(ConvertTypeForMem(E->getType()));
if (auto *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) {
Expand Down Expand Up @@ -4810,9 +4793,6 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
for (CallLifetimeEnd &LifetimeEnd : CallLifetimeEndAfterCall)
LifetimeEnd.Emit(*this, /*Flags=*/{});

for (auto &LT : CallArgs.getLifetimeCleanups())
EmitLifetimeEnd(LT.Size, LT.Addr);

return Ret;
}

Expand Down
20 changes: 0 additions & 20 deletions clang/lib/CodeGen/CGCall.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,11 +283,6 @@ class CallArgList : public SmallVector<CallArg, 8> {
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) {
Expand All @@ -304,9 +299,6 @@ class CallArgList : public SmallVector<CallArg, 8> {
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;
Expand Down Expand Up @@ -346,14 +338,6 @@ class CallArgList : public SmallVector<CallArg, 8> {
/// 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;

Expand All @@ -362,10 +346,6 @@ class CallArgList : public SmallVector<CallArg, 8> {
/// 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;
};
Expand Down
83 changes: 0 additions & 83 deletions clang/test/CodeGen/lifetime-call-temp.c

This file was deleted.

19 changes: 0 additions & 19 deletions clang/test/CodeGenCXX/amdgcn-call-with-aggarg.cpp

This file was deleted.

9 changes: 0 additions & 9 deletions clang/test/CodeGenCXX/stack-reuse-miscompile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ const char * f(S s)
// CHECK: [[T2:%.*]] = alloca %class.T, align 4
// CHECK: [[T3:%.*]] = alloca %class.T, align 4
//
// CHECK: [[AGG:%.*]] = alloca %class.S, align 4
//
// FIXME: We could defer starting the lifetime of the return object of concat
// until the call.
// CHECK: [[T1i8:%.*]] = bitcast %class.T* [[T1]] to i8*
Expand All @@ -39,15 +37,8 @@ const char * f(S s)
//
// CHECK: [[T3i8:%.*]] = bitcast %class.T* [[T3]] to i8*
// CHECK: call void @llvm.lifetime.start.p0i8(i64 16, i8* [[T3i8]])
//
// CHECK: [[AGGi8:%.*]] = bitcast %class.S* [[AGG]] to i8*
// CHECK: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[AGGi8]])
//
// CHECK: [[T5:%.*]] = call %class.T* @_ZN1TC1E1S(%class.T* [[T3]], [2 x i32] %{{.*}})
//
// CHECK: [[AGGi8:%.*]] = bitcast %class.S* {{.*}} to i8*
// CHECK: call void @llvm.lifetime.end.p0i8(i64 8, i8* [[AGGi8]])
//
// CHECK: call void @_ZNK1T6concatERKS_(%class.T* sret [[T1]], %class.T* [[T2]], %class.T* dereferenceable(16) [[T3]])
// CHECK: [[T6:%.*]] = call i8* @_ZNK1T3strEv(%class.T* [[T1]])
//
Expand Down

0 comments on commit e26c24b

Please sign in to comment.