[llvm] 7fc279c - [GlobalOpt] Don't remove inalloca from musttail-called functions
Hans Wennborg via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 7 10:03:02 PDT 2020
Author: Hans Wennborg
Date: 2020-07-07T19:02:46+02:00
New Revision: 7fc279ca3d414c0997998cb30d1adc2c63c837a5
URL: https://github.com/llvm/llvm-project/commit/7fc279ca3d414c0997998cb30d1adc2c63c837a5
DIFF: https://github.com/llvm/llvm-project/commit/7fc279ca3d414c0997998cb30d1adc2c63c837a5.diff
LOG: [GlobalOpt] Don't remove inalloca from musttail-called functions
Otherwise the verifier complains about the mismatching function ABIs.
Differential revision: https://reviews.llvm.org/D83300
Added:
Modified:
llvm/lib/Transforms/IPO/GlobalOpt.cpp
llvm/test/Transforms/GlobalOpt/fastcc.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
index ed989529d1ae..d9fb820f7cb5 100644
--- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
@@ -2442,7 +2442,7 @@ OptimizeFunctions(Module &M,
// 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;
}
diff --git a/llvm/test/Transforms/GlobalOpt/fastcc.ll b/llvm/test/Transforms/GlobalOpt/fastcc.ll
index 9c9076d0155b..edd0688ea92b 100644
--- a/llvm/test/Transforms/GlobalOpt/fastcc.ll
+++ b/llvm/test/Transforms/GlobalOpt/fastcc.ll
@@ -35,6 +35,17 @@ define internal i32 @inalloca(i32* inalloca %p) {
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
More information about the llvm-commits
mailing list