[PATCH] D83021: [Inliner] Don't skip inlining alwaysinline in optnone functions
Arthur Eubanks via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 1 21:11:28 PDT 2020
aeubanks created this revision.
Herald added subscribers: llvm-commits, hiraditya, eraman.
Herald added a project: LLVM.
Previously the NPM inliner would skip all potential inlines in an
optnone function, but alwaysinline callees should be inlined regardless
of optnone.
Fixes inline-optnone.ll under NPM.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D83021
Files:
llvm/lib/Transforms/IPO/Inliner.cpp
llvm/test/Transforms/Inline/inline-optnone.ll
Index: llvm/test/Transforms/Inline/inline-optnone.ll
===================================================================
--- llvm/test/Transforms/Inline/inline-optnone.ll
+++ llvm/test/Transforms/Inline/inline-optnone.ll
@@ -1,4 +1,5 @@
; RUN: opt < %s -inline -S | FileCheck %s
+; RUN: opt < %s --passes=inline -S | FileCheck %s
; Test that functions with attribute optnone are not inlined.
; Also test that only functions with attribute alwaysinline are
Index: llvm/lib/Transforms/IPO/Inliner.cpp
===================================================================
--- llvm/lib/Transforms/IPO/Inliner.cpp
+++ llvm/lib/Transforms/IPO/Inliner.cpp
@@ -48,6 +48,7 @@
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
+#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PassManager.h"
@@ -801,7 +802,9 @@
LazyCallGraph::Node &N = *CG.lookup(F);
if (CG.lookupSCC(N) != C)
continue;
- if (F.hasOptNone()) {
+ if (!Calls[I].first->getCalledFunction()->hasFnAttribute(
+ Attribute::AlwaysInline) &&
+ F.hasOptNone()) {
setInlineRemark(*Calls[I].first, "optnone attribute");
continue;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83021.274999.patch
Type: text/x-patch
Size: 1260 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200702/6428e1ce/attachment.bin>
More information about the llvm-commits
mailing list