Skip to content

Commit

Permalink
[Inliner] Don't skip inlining alwaysinline in optnone functions
Browse files Browse the repository at this point in the history
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.

Reviewed By: kazu

Differential Revision: https://reviews.llvm.org/D83021
  • Loading branch information
aeubanks committed Jul 7, 2020
1 parent 6404fb4 commit 2279380
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion llvm/lib/Transforms/IPO/Inliner.cpp
Expand Up @@ -791,7 +791,9 @@ PreservedAnalyses InlinerPass::run(LazyCallGraph::SCC &InitialC,
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;
}
Expand Down
1 change: 1 addition & 0 deletions 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
Expand Down

0 comments on commit 2279380

Please sign in to comment.