[llvm] r265101 - Don't insert stackrestore on deoptimizing returns
Sanjoy Das via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 31 19:51:30 PDT 2016
Author: sanjoy
Date: Thu Mar 31 21:51:30 2016
New Revision: 265101
URL: http://llvm.org/viewvc/llvm-project?rev=265101&view=rev
Log:
Don't insert stackrestore on deoptimizing returns
They're not necessary (since the stack pointer is trivially restored on
return), and the way LLVM inserts the stackrestore calls breaks the
IR (we get a stackrestore between the deoptimize call and the return).
Modified:
llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp
llvm/trunk/test/Transforms/Inline/deoptimize-intrinsic.ll
Modified: llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp?rev=265101&r1=265100&r2=265101&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Thu Mar 31 21:51:30 2016
@@ -1731,10 +1731,12 @@ bool llvm::InlineFunction(CallSite CS, I
// Insert a call to llvm.stackrestore before any return instructions in the
// inlined function.
for (ReturnInst *RI : Returns) {
- // Don't insert llvm.stackrestore calls between a musttail call and a
- // return. The return will restore the stack pointer.
+ // Don't insert llvm.stackrestore calls between a musttail or deoptimize
+ // call and a return. The return will restore the stack pointer.
if (InlinedMustTailCalls && RI->getParent()->getTerminatingMustTailCall())
continue;
+ if (InlinedDeoptimizeCalls && RI->getParent()->getTerminatingDeoptimizeCall())
+ continue;
IRBuilder<>(RI).CreateCall(StackRestore, SavedPtr);
}
}
Modified: llvm/trunk/test/Transforms/Inline/deoptimize-intrinsic.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Inline/deoptimize-intrinsic.ll?rev=265101&r1=265100&r2=265101&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/Inline/deoptimize-intrinsic.ll (original)
+++ llvm/trunk/test/Transforms/Inline/deoptimize-intrinsic.ll Thu Mar 31 21:51:30 2016
@@ -104,3 +104,19 @@ entry:
call i8 @callee_with_alloca();
ret void
}
+
+define i8 @callee_with_dynamic_alloca(i32 %n) alwaysinline {
+ %p = alloca i8, i32 %n
+ %v = call i8(...) @llvm.experimental.deoptimize.i8(i32 1) [ "deopt"(i8* %p) ]
+ ret i8 %v
+}
+
+define void @caller_with_stacksaverestore(i32 %n) {
+; CHECK-LABEL: void @caller_with_stacksaverestore(
+; CHECK: call void (...) @llvm.experimental.deoptimize.isVoid(i32 1) [ "deopt"(i8* %p.i) ]
+; CHECK-NEXT: ret void
+
+ %p = alloca i32, i32 %n
+ call i8 @callee_with_dynamic_alloca(i32 %n)
+ ret void
+}
More information about the llvm-commits
mailing list