r245965 - Revert r245879. Speculative, might have caused crbug.com/524604
Nico Weber via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 25 11:43:33 PDT 2015
Author: nico
Date: Tue Aug 25 13:43:32 2015
New Revision: 245965
URL: http://llvm.org/viewvc/llvm-project?rev=245965&view=rev
Log:
Revert r245879. Speculative, might have caused crbug.com/524604
Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGCall.h
cfe/trunk/test/CodeGenCXX/microsoft-abi-arg-order.cpp
cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=245965&r1=245964&r2=245965&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Tue Aug 25 13:43:32 2015
@@ -2782,11 +2782,21 @@ void CallArgList::allocateArgumentMemory
// alloca and store lazily on the first cleanup emission.
StackBaseMem = CGF.CreateTempAlloca(CGF.Int8PtrTy, "inalloca.spmem");
CGF.Builder.CreateStore(StackBase, StackBaseMem);
- CGF.pushStackRestore(NormalCleanup, StackBaseMem);
+ CGF.pushStackRestore(EHCleanup, StackBaseMem);
StackCleanup = CGF.EHStack.getInnermostEHScope();
assert(StackCleanup.isValid());
}
+void CallArgList::freeArgumentMemory(CodeGenFunction &CGF) const {
+ if (StackBase) {
+ CGF.DeactivateCleanupBlock(StackCleanup, StackBase);
+ llvm::Value *F = CGF.CGM.getIntrinsic(llvm::Intrinsic::stackrestore);
+ // We could load StackBase from StackBaseMem, but in the non-exceptional
+ // case we can skip it.
+ CGF.Builder.CreateCall(F, StackBase);
+ }
+}
+
void CodeGenFunction::EmitNonNullArgCheck(RValue RV, QualType ArgType,
SourceLocation ArgLoc,
const FunctionDecl *FD,
@@ -3523,6 +3533,10 @@ RValue CodeGenFunction::EmitCall(const C
if (CallArgs.hasWritebacks())
emitWritebacks(*this, CallArgs);
+ // The stack cleanup for inalloca arguments has to run out of the normal
+ // lexical order, so deactivate it and run it manually here.
+ CallArgs.freeArgumentMemory(*this);
+
RValue Ret = [&] {
switch (RetAI.getKind()) {
case ABIArgInfo::InAlloca:
Modified: cfe/trunk/lib/CodeGen/CGCall.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.h?rev=245965&r1=245964&r2=245965&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.h (original)
+++ cfe/trunk/lib/CodeGen/CGCall.h Tue Aug 25 13:43:32 2015
@@ -120,6 +120,7 @@ namespace CodeGen {
void allocateArgumentMemory(CodeGenFunction &CGF);
llvm::Instruction *getStackBase() const { return StackBase; }
+ void freeArgumentMemory(CodeGenFunction &CGF) const;
/// \brief Returns if we're using an inalloca struct to pass arguments in
/// memory.
Modified: cfe/trunk/test/CodeGenCXX/microsoft-abi-arg-order.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-arg-order.cpp?rev=245965&r1=245964&r2=245965&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-arg-order.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-arg-order.cpp Tue Aug 25 13:43:32 2015
@@ -42,12 +42,12 @@ void call_foo() {
// X86: call i8* @llvm.stacksave()
// X86: %[[argmem:[^ ]*]] = alloca inalloca [[argmem_ty]]
// X86: %[[arg3:[^ ]*]] = getelementptr inbounds [[argmem_ty]], [[argmem_ty]]* %[[argmem]], i32 0, i32 2
-// X86: call x86_thiscallcc %struct.A* @"\01??0A@@QAE at H@Z"(%struct.A* %[[arg3]], i32 3)
+// X86: invoke x86_thiscallcc %struct.A* @"\01??0A@@QAE at H@Z"(%struct.A* %[[arg3]], i32 3)
// X86: %[[arg2:[^ ]*]] = getelementptr inbounds [[argmem_ty]], [[argmem_ty]]* %[[argmem]], i32 0, i32 1
// X86: invoke x86_thiscallcc %struct.A* @"\01??0A@@QAE at H@Z"(%struct.A* %[[arg2]], i32 2)
// X86: %[[arg1:[^ ]*]] = getelementptr inbounds [[argmem_ty]], [[argmem_ty]]* %[[argmem]], i32 0, i32 0
// X86: invoke x86_thiscallcc %struct.A* @"\01??0A@@QAE at H@Z"(%struct.A* %[[arg1]], i32 1)
-// X86: call void @"\01?foo@@YAXUA@@00 at Z"([[argmem_ty]]* inalloca %[[argmem]])
+// X86: invoke void @"\01?foo@@YAXUA@@00 at Z"([[argmem_ty]]* inalloca %[[argmem]])
// X86: call void @llvm.stackrestore
// X86: ret void
//
Modified: cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp?rev=245965&r1=245964&r2=245965&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp Tue Aug 25 13:43:32 2015
@@ -17,17 +17,18 @@ void HasEHCleanup() {
// WIN32-LABEL: define void @"\01?HasEHCleanup@@YAXXZ"() {{.*}} {
// WIN32: %[[base:.*]] = call i8* @llvm.stacksave()
// If this call throws, we have to restore the stack.
-// WIN32: call void @"\01?getA@@YA?AUA@@XZ"(%struct.A* sret %{{.*}})
+// WIN32: invoke void @"\01?getA@@YA?AUA@@XZ"(%struct.A* sret %{{.*}})
// If this call throws, we have to cleanup the first temporary.
// WIN32: invoke void @"\01?getA@@YA?AUA@@XZ"(%struct.A* sret %{{.*}})
// If this call throws, we have to cleanup the stacksave.
-// WIN32: call i32 @"\01?TakesTwo@@YAHUA@@0 at Z"
-// WIN32: call void @llvm.stackrestore
+// WIN32: invoke i32 @"\01?TakesTwo@@YAHUA@@0 at Z"
+// WIN32: call void @llvm.stackrestore(i8* %[[base]])
// WIN32: ret void
//
// There should be one dtor call for unwinding from the second getA.
-// WIN32: call x86_thiscallcc void @"\01??1A@@QAE at XZ"
+// WIN32: invoke x86_thiscallcc void @"\01??1A@@QAE at XZ"
// WIN32-NOT: @"\01??1A@@QAE at XZ"
+// WIN32: call void @llvm.stackrestore
// WIN32: }
void TakeRef(const A &a);
@@ -40,7 +41,7 @@ int HasDeactivatedCleanups() {
// WIN32: call i8* @llvm.stacksave()
// WIN32: %[[argmem:.*]] = alloca inalloca [[argmem_ty:<{ %struct.A, %struct.A }>]]
// WIN32: %[[arg1:.*]] = getelementptr inbounds [[argmem_ty]], [[argmem_ty]]* %[[argmem]], i32 0, i32 1
-// WIN32: call x86_thiscallcc %struct.A* @"\01??0A@@QAE at XZ"
+// WIN32: invoke x86_thiscallcc %struct.A* @"\01??0A@@QAE at XZ"
// WIN32: invoke void @"\01?TakeRef@@YAXABUA@@@Z"
//
// WIN32: invoke x86_thiscallcc %struct.A* @"\01??0A@@QAE at XZ"(%struct.A* %[[arg1]])
@@ -53,9 +54,10 @@ int HasDeactivatedCleanups() {
// WIN32: store i1 false, i1* %[[isactive]]
//
// WIN32: invoke i32 @"\01?TakesTwo@@YAHUA@@0 at Z"([[argmem_ty]]* inalloca %[[argmem]])
+// WIN32: call void @llvm.stackrestore
// Destroy the two const ref temporaries.
// WIN32: invoke x86_thiscallcc void @"\01??1A@@QAE at XZ"
-// WIN32: call x86_thiscallcc void @"\01??1A@@QAE at XZ"
+// WIN32: invoke x86_thiscallcc void @"\01??1A@@QAE at XZ"
// WIN32: ret i32
//
// Conditionally destroy arg1.
@@ -74,18 +76,18 @@ int HasConditionalCleanup(bool cond) {
// WIN32: store i1 false
// WIN32: br i1
// WIN32: call i8* @llvm.stacksave()
-// WIN32: call x86_thiscallcc %struct.A* @"\01??0A@@QAE at XZ"(%struct.A* %{{.*}})
+// WIN32: invoke x86_thiscallcc %struct.A* @"\01??0A@@QAE at XZ"(%struct.A* %{{.*}})
// WIN32: store i1 true
// WIN32: invoke x86_thiscallcc %struct.A* @"\01??0A@@QAE at XZ"(%struct.A* %{{.*}})
-// WIN32: call i32 @"\01?TakesTwo@@YAHUA@@0 at Z"
+// WIN32: invoke i32 @"\01?TakesTwo@@YAHUA@@0 at Z"
+// WIN32: call void @llvm.stackrestore
//
// WIN32: call i32 @"\01?CouldThrow@@YAHXZ"()
//
-// WIN32: call void @llvm.stackrestore
-//
// Only one dtor in the invoke for arg1
-// WIN32: call x86_thiscallcc void @"\01??1A@@QAE at XZ"({{.*}})
+// WIN32: invoke x86_thiscallcc void @"\01??1A@@QAE at XZ"({{.*}})
// WIN32-NOT: invoke x86_thiscallcc void @"\01??1A@@QAE at XZ"
+// WIN32: call void @llvm.stackrestore
// WIN32: }
// Now test both.
@@ -103,7 +105,7 @@ int HasConditionalDeactivatedCleanups(bo
// WIN32: store i1 false
// WIN32: br i1
// True condition.
-// WIN32: call x86_thiscallcc %struct.A* @"\01??0A@@QAE at XZ"
+// WIN32: invoke x86_thiscallcc %struct.A* @"\01??0A@@QAE at XZ"
// WIN32: store i1 true
// WIN32: invoke void @"\01?TakeRef@@YAXABUA@@@Z"
// WIN32: invoke x86_thiscallcc %struct.A* @"\01??0A@@QAE at XZ"
@@ -119,7 +121,7 @@ int HasConditionalDeactivatedCleanups(bo
// WIN32: invoke i32 @"\01?CouldThrow@@YAHXZ"()
// Two normal cleanups for TakeRef args.
// WIN32: invoke x86_thiscallcc void @"\01??1A@@QAE at XZ"
-// WIN32-NOT: invoke x86_thiscallcc void @"\01??1A@@QAE at XZ"
+// WIN32: invoke x86_thiscallcc void @"\01??1A@@QAE at XZ"
// WIN32: ret i32
//
// Somewhere in the landing pad soup, we conditionally destroy arg1.
More information about the cfe-commits
mailing list