summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorJohannes Doerfert <jdoerfert@anl.gov>2019-08-16 21:59:52 +0000
committerJohannes Doerfert <jdoerfert@anl.gov>2019-08-16 21:59:52 +0000
commitf72d9b1c97b41fff48ad1eecbba59a29c171bff4 (patch)
tree15d13f1aef1b009c6acfc472b1c7f81f683dd1e3 /llvm/lib/Transforms
parentcbaf1fdea2de891bdbc49cdec89ae2077e6b9ed0 (diff)
downloadbcm5719-llvm-f72d9b1c97b41fff48ad1eecbba59a29c171bff4.tar.gz
bcm5719-llvm-f72d9b1c97b41fff48ad1eecbba59a29c171bff4.zip
[Attributor] Fix: Do not partially resolve returned calls.
By partially resolving returned calls we did not record that they were not fully resolved which caused odd behavior down the line. We could also end up with some, but not all, returned values of the callee in the returned values map of the caller, another odd behavior we want to avoid. llvm-svn: 369160
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/IPO/Attributor.cpp39
1 files changed, 28 insertions, 11 deletions
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index 882d0931f9f..62ec3937dcf 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -943,12 +943,35 @@ ChangeStatus AAReturnedValuesImpl::updateImpl(Attributor &A) {
<< static_cast<const AbstractAttribute &>(RetValAA)
<< "\n");
- // If we know something but not everyting about the returned values, keep
- // track of that too. Hence, remember transitively unresolved calls.
- UnresolvedCalls.insert(RetValAA.getUnresolvedCalls().begin(),
- RetValAA.getUnresolvedCalls().end());
+ // Do not try to learn partial information. If the callee has unresolved
+ // return values we will treat the call as unresolved/opaque.
+ auto &RetValAAUnresolvedCalls = RetValAA.getUnresolvedCalls();
+ if (!RetValAAUnresolvedCalls.empty()) {
+ UnresolvedCalls.insert(CB);
+ continue;
+ }
+
+ // Now check if we can track transitively returned values. If possible, thus
+ // if all return value can be represented in the current scope, do so.
+ bool Unresolved = false;
+ for (auto &RetValAAIt : RetValAA.returned_values()) {
+ Value *RetVal = RetValAAIt.first;
+ if (isa<Argument>(RetVal) || isa<CallBase>(RetVal) ||
+ isa<Constant>(RetVal))
+ continue;
+ // Anything that did not fit in the above categories cannot be resolved,
+ // mark the call as unresolved.
+ LLVM_DEBUG(dbgs() << "[AAReturnedValues] transitively returned value "
+ "cannot be translated: "
+ << *RetVal << "\n");
+ UnresolvedCalls.insert(CB);
+ Unresolved = true;
+ break;
+ }
+
+ if (Unresolved)
+ continue;
- // Now track transitively returned values.
for (auto &RetValAAIt : RetValAA.returned_values()) {
Value *RetVal = RetValAAIt.first;
if (Argument *Arg = dyn_cast<Argument>(RetVal)) {
@@ -967,12 +990,6 @@ ChangeStatus AAReturnedValuesImpl::updateImpl(Attributor &A) {
NewRVsMap[RetVal].insert(It.second.begin(), It.second.end());
continue;
}
- // Anything that did not fit in the above categories cannot be resolved,
- // mark the call as unresolved.
- LLVM_DEBUG(dbgs() << "[AAReturnedValues] transitively returned value "
- "cannot be translated: "
- << *RetVal << "\n");
- UnresolvedCalls.insert(CB);
}
}
OpenPOWER on IntegriCloud