diff options
author | Davide Italiano <davide@freebsd.org> | 2017-02-01 18:52:20 +0000 |
---|---|---|
committer | Davide Italiano <davide@freebsd.org> | 2017-02-01 18:52:20 +0000 |
commit | 0eeb4b90fe25a3505db161b7c42004616b00c015 (patch) | |
tree | 72c1304b878e5ad8d1ff95946ef043f6b36f06ac /lib/Transforms/Scalar/SCCP.cpp | |
parent | 28f9c9871d56f15f8bd93951af53e9347d6488ac (diff) |
[IPSCCP] Don't propagate return values of functions marked as noinline.
This tries to address what Hal defined (in the post-commit review of
r293727) a long-standing problem with noinline, where we end up
de facto inlining trivial functions e.g.
__attribute__((noinline)) int patatino(void) { return 5; }
because of return value propagation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293799 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/SCCP.cpp')
-rw-r--r-- | lib/Transforms/Scalar/SCCP.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp index dd1123fd4fa..054ad712d38 100644 --- a/lib/Transforms/Scalar/SCCP.cpp +++ b/lib/Transforms/Scalar/SCCP.cpp @@ -1715,7 +1715,12 @@ static bool runIPSCCP(Module &M, const DataLayout &DL, // Don't touch naked functions. They may contain asm returning a // value we don't see, so we may end up interprocedurally propagating // the return value incorrectly. - if (F.hasExactDefinition() && !F.hasFnAttribute(Attribute::Naked)) + // Also, don't touch functions marked as noinline. Trivial functions may + // essentially be inlined because of return value propagation. + // (e.g. int tinkywinky(void) { return 666; }) + if (F.hasExactDefinition() && + !(F.hasFnAttribute(Attribute::Naked) || + F.hasFnAttribute(Attribute::NoInline))) Solver.AddTrackedFunction(&F); // If this function only has direct calls that we can see, we can track its |