diff options
| author | Johannes Doerfert <johannes@jdoerfert.de> | 2019-10-31 20:15:02 -0500 |
|---|---|---|
| committer | Johannes Doerfert <johannes@jdoerfert.de> | 2019-11-02 00:28:24 -0500 |
| commit | c36e2ebf9ff5fa869bd5717616e71a0d406d0306 (patch) | |
| tree | 08e4c56068a153ba8a11f1ebc098abc53b517418 /llvm/lib/Transforms/IPO | |
| parent | 0437bfcc8338ec79f1d209daf975b9555e51e4b1 (diff) | |
| download | bcm5719-llvm-c36e2ebf9ff5fa869bd5717616e71a0d406d0306.tar.gz bcm5719-llvm-c36e2ebf9ff5fa869bd5717616e71a0d406d0306.zip | |
[Attributor][NFCI] Avoid unnecessary work except for testing
Trying to deduce information for declarations and calls sites of
declarations is not useful in practice but only for testing. Add a flag
that disables this by default but also enable it in the tests.
The misc.ll test will verify the flag "works" as expected.
Diffstat (limited to 'llvm/lib/Transforms/IPO')
| -rw-r--r-- | llvm/lib/Transforms/IPO/Attributor.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp index 6f0a4a85890..ddd2ff076e1 100644 --- a/llvm/lib/Transforms/IPO/Attributor.cpp +++ b/llvm/lib/Transforms/IPO/Attributor.cpp @@ -120,6 +120,10 @@ static cl::opt<bool> DisableAttributor( cl::desc("Disable the attributor inter-procedural deduction pass."), cl::init(true)); +static cl::opt<bool> AnnotateDeclarationCallSites( + "attributor-annotate-decl-cs", cl::Hidden, + cl::desc("Annoate call sites of function declarations."), cl::init(false)); + static cl::opt<bool> ManifestInternal( "attributor-manifest-internal", cl::Hidden, cl::desc("Manifest Attributor internal string attributes."), @@ -5074,6 +5078,8 @@ void Attributor::recordDependence(const AbstractAttribute &FromAA, void Attributor::identifyDefaultAbstractAttributes(Function &F) { if (!VisitedFunctions.insert(&F).second) return; + if (F.isDeclaration()) + return; IRPosition FPos = IRPosition::function(F); @@ -5170,7 +5176,12 @@ void Attributor::identifyDefaultAbstractAttributes(Function &F) { auto CallSitePred = [&](Instruction &I) -> bool { CallSite CS(&I); if (Function *Callee = CS.getCalledFunction()) { - if (!Callee->getReturnType()->isVoidTy()) { + // Skip declerations except if annotations on their call sites were + // explicitly requested. + if (!AnnotateDeclarationCallSites && Callee->isDeclaration()) + return true; + + if (!Callee->getReturnType()->isVoidTy() && !CS->use_empty()) { IRPosition CSRetPos = IRPosition::callsite_returned(CS); // Call site return values might be dead. |

