summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/SCCP.cpp
diff options
context:
space:
mode:
authorDavide Italiano <davide@freebsd.org>2017-02-01 18:52:20 +0000
committerDavide Italiano <davide@freebsd.org>2017-02-01 18:52:20 +0000
commit6849f20d8524c570ece1c24e0af4c0d6889763f4 (patch)
treec462afba452035feba9f8c0fcc712c10353f5a10 /llvm/lib/Transforms/Scalar/SCCP.cpp
parentac9c30c37fcbd5f5d23e976e42e28375d28356dd (diff)
downloadbcm5719-llvm-6849f20d8524c570ece1c24e0af4c0d6889763f4.tar.gz
bcm5719-llvm-6849f20d8524c570ece1c24e0af4c0d6889763f4.zip
[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. llvm-svn: 293799
Diffstat (limited to 'llvm/lib/Transforms/Scalar/SCCP.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/SCCP.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/SCCP.cpp b/llvm/lib/Transforms/Scalar/SCCP.cpp
index dd1123fd4fa..054ad712d38 100644
--- a/llvm/lib/Transforms/Scalar/SCCP.cpp
+++ b/llvm/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
OpenPOWER on IntegriCloud