Skip to content

Commit 90f185c

Browse files
Revert "[AlwaysInliner] Enable call site inlining to make flatten attribute working again (#53360)"
This reverts commit ceec438. Clang tests fail.
1 parent ceec438 commit 90f185c

File tree

5 files changed

+33
-11
lines changed

5 files changed

+33
-11
lines changed

clang/test/CodeGen/flatten.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
// UNSUPPORTED: experimental-new-pass-manager
2+
// Currently, different code seems to be intentionally generated under the new
3+
// PM since we alwaysinline functions and not callsites under new PM.
4+
// Under new PM, f() will not be inlined from g() since f is not marked as
5+
// alwaysinline.
6+
17
// RUN: %clang_cc1 -triple=x86_64-linux-gnu %s -emit-llvm -o - | FileCheck %s
28

39
void f(void) {}

clang/test/CodeGenCXX/flatten.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// UNSUPPORTED: experimental-new-pass-manager
2+
// See the comment for CodeGen/flatten.c on why this is unsupported with the new
3+
// PM.
4+
15
// RUN: %clang_cc1 -triple=x86_64-linux-gnu -std=c++11 %s -emit-llvm -o - | FileCheck %s
26

37
void f(void) {}

llvm/lib/Transforms/IPO/AlwaysInliner.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ PreservedAnalyses AlwaysInlinerPass::run(Module &M,
5454
if (F.isPresplitCoroutine())
5555
continue;
5656

57-
if (!F.isDeclaration() && isInlineViable(F).isSuccess()) {
57+
if (!F.isDeclaration() && F.hasFnAttribute(Attribute::AlwaysInline) &&
58+
isInlineViable(F).isSuccess()) {
5859
Calls.clear();
5960

6061
for (User *U : F.users())
6162
if (auto *CB = dyn_cast<CallBase>(U))
62-
if (CB->getCalledFunction() == &F &&
63-
CB->hasFnAttr(Attribute::AlwaysInline))
63+
if (CB->getCalledFunction() == &F)
6464
Calls.insert(CB);
6565

6666
for (CallBase *CB : Calls) {

llvm/test/Transforms/Coroutines/coro-retcon-once-private.ll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
44
target triple = "x86_64-apple-macosx10.12.0"
55

6-
; CHECK-NOT: define {{.*}} @f(i8* %buffer, i32* %array)
6+
; CHECK: define internal { i8*, i32 } @f(i8* %buffer, i32* %array)
7+
; CHECK-NEXT: entry:
8+
; CHECK-NEXT: unreachable
79

810
define internal {i8*, i32} @f(i8* %buffer, i32* %array) {
911
entry:

llvm/test/Transforms/Inline/always-inline.ll

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
; RUN: opt < %s -inline-threshold=0 -always-inline -enable-new-pm=0 -S | FileCheck %s --check-prefix=CHECK
1+
; RUN: opt < %s -inline-threshold=0 -always-inline -enable-new-pm=0 -S | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-CALL
22
;
33
; Ensure the threshold has no impact on these decisions.
4-
; RUN: opt < %s -inline-threshold=20000000 -always-inline -enable-new-pm=0 -S | FileCheck %s --check-prefix=CHECK
5-
; RUN: opt < %s -inline-threshold=-20000000 -always-inline -enable-new-pm=0 -S | FileCheck %s --check-prefix=CHECK
4+
; RUN: opt < %s -inline-threshold=20000000 -always-inline -enable-new-pm=0 -S | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-CALL
5+
; RUN: opt < %s -inline-threshold=-20000000 -always-inline -enable-new-pm=0 -S | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-CALL
66
;
77
; The new pass manager doesn't re-use any threshold based infrastructure for
8-
; the always inliner, but test that we get the correct result.
8+
; the always inliner, but test that we get the correct result. The new PM
9+
; always inliner also doesn't support inlining call-site alwaysinline
10+
; annotations. It isn't clear that this is a reasonable use case for
11+
; 'alwaysinline'.
912
; RUN: opt < %s -inline-threshold=0 -passes=always-inline -S | FileCheck %s --check-prefix=CHECK
1013
; RUN: opt < %s -inline-threshold=20000000 -passes=always-inline -S | FileCheck %s --check-prefix=CHECK
1114
; RUN: opt < %s -inline-threshold=-20000000 -passes=always-inline -S | FileCheck %s --check-prefix=CHECK
@@ -23,6 +26,12 @@ define i32 @outer1() {
2326
ret i32 %r
2427
}
2528

29+
; The always inliner can't DCE arbitrary internal functions. PR2945
30+
define internal i32 @pr2945() nounwind {
31+
; CHECK-LABEL: @pr2945(
32+
ret i32 0
33+
}
34+
2635
define internal void @inner2(i32 %N) alwaysinline {
2736
; CHECK-NOT: @inner2(
2837
%P = alloca i32, i32 %N
@@ -137,9 +146,10 @@ define i32 @inner7() {
137146
ret i32 1
138147
}
139148
define i32 @outer7() {
140-
; CHECK-LABEL: @outer7(
141-
; CHECK-NOT: call
142-
; CHECK: ret
149+
; CHECK-CALL-LABEL: @outer7(
150+
; CHECK-CALL-NOT: call
151+
; CHECK-CALL: ret
152+
143153
%r = call i32 @inner7() alwaysinline
144154
ret i32 %r
145155
}

0 commit comments

Comments
 (0)