[PATCH] D86988: [Inliner] Run always-inliner in inliner-wrapper
Arthur Eubanks via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 1 16:14:57 PDT 2020
aeubanks created this revision.
Herald added subscribers: llvm-commits, hiraditya, eraman.
Herald added a project: LLVM.
aeubanks requested review of this revision.
An alwaysinline function may not get inlined in inliner-wrapper due to
the inlining order.
Previously for the following, the inliner would first inline @a() into @b(),
define void @a() {
entry:
call void @b()
ret void
}
define void @b() alwaysinline {
entry:
br label %for.cond
for.cond:
call void @a()
br label %for.cond
}
making @b() recursive and unable to be inlined into @a(), ending at
define void @a() {
entry:
call void @b()
ret void
}
define void @b() alwaysinline {
entry:
br label %for.cond
for.cond:
call void @b()
br label %for.cond
}
Running always-inliner first makes sure that we respect alwaysinline in more cases.
Fixes https://bugs.llvm.org/show_bug.cgi?id=46945.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D86988
Files:
llvm/lib/Transforms/IPO/Inliner.cpp
llvm/test/Transforms/Inline/pr46945.ll
Index: llvm/test/Transforms/Inline/pr46945.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/Inline/pr46945.ll
@@ -0,0 +1,18 @@
+; RUN: opt %s -o - -S -passes=inliner-wrapper | FileCheck %s
+
+; CHECK-NOT: call void @b()
+define void @a() {
+entry:
+ call void @b()
+ ret void
+}
+
+define void @b() alwaysinline {
+entry:
+ br label %for.cond
+
+for.cond:
+ call void @a()
+ br label %for.cond
+}
+
Index: llvm/lib/Transforms/IPO/Inliner.cpp
===================================================================
--- llvm/lib/Transforms/IPO/Inliner.cpp
+++ llvm/lib/Transforms/IPO/Inliner.cpp
@@ -58,6 +58,7 @@
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
+#include "llvm/Transforms/IPO/AlwaysInliner.h"
#include "llvm/Transforms/Utils/CallPromotionUtils.h"
#include "llvm/Transforms/Utils/Cloning.h"
#include "llvm/Transforms/Utils/ImportedFunctionsInliningStatistics.h"
@@ -1055,6 +1056,7 @@
return PreservedAnalyses::all();
}
+ MPM.addPass(AlwaysInlinerPass());
// We wrap the CGSCC pipeline in a devirtualization repeater. This will try
// to detect when we devirtualize indirect calls and iterate the SCC passes
// in that case to try and catch knock-on inlining or function attrs
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86988.289306.patch
Type: text/x-patch
Size: 1338 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200901/d0b84997/attachment.bin>
More information about the llvm-commits
mailing list