[PATCH] D83300: [GlobalOpt] Don't remove inalloca from musttail-called functions
Hans Wennborg via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 7 10:03:12 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7fc279ca3d41: [GlobalOpt] Don't remove inalloca from musttail-called functions (authored by hans).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D83300/new/
https://reviews.llvm.org/D83300
Files:
llvm/lib/Transforms/IPO/GlobalOpt.cpp
llvm/test/Transforms/GlobalOpt/fastcc.ll
Index: llvm/test/Transforms/GlobalOpt/fastcc.ll
===================================================================
--- llvm/test/Transforms/GlobalOpt/fastcc.ll
+++ llvm/test/Transforms/GlobalOpt/fastcc.ll
@@ -35,6 +35,17 @@
ret i32 %rv
}
+define i32 @inalloca2_caller(i32* inalloca %p) {
+ %rv = musttail call i32 @inalloca2(i32* inalloca %p)
+ ret i32 %rv
+}
+define internal i32 @inalloca2(i32* inalloca %p) {
+; Because of the musttail caller, this inalloca cannot be dropped.
+; CHECK-LABEL: define internal i32 @inalloca2(i32* inalloca %p)
+ %rv = load i32, i32* %p
+ ret i32 %rv
+}
+
define internal i32 @preallocated(i32* preallocated(i32) %p) {
; CHECK-LABEL: define internal fastcc i32 @preallocated(i32* %p)
%rv = load i32, i32* %p
Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
===================================================================
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp
@@ -2442,7 +2442,7 @@
// FIXME: We should also hoist alloca affected by this to the entry
// block if possible.
if (F->getAttributes().hasAttrSomewhere(Attribute::InAlloca) &&
- !F->hasAddressTaken()) {
+ !F->hasAddressTaken() && !hasMustTailCallers(F)) {
RemoveAttribute(F, Attribute::InAlloca);
Changed = true;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83300.276115.patch
Type: text/x-patch
Size: 1318 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200707/512c65ad/attachment.bin>
More information about the llvm-commits
mailing list