summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorJohannes Doerfert <jdoerfert@anl.gov>2019-10-13 20:47:16 +0000
committerJohannes Doerfert <jdoerfert@anl.gov>2019-10-13 20:47:16 +0000
commit8ee410c75ec416ea02dabeddd03fb062ab5dc92e (patch)
tree4402cd576b41e4e5be8b0a4d9c3604d768e4243d /llvm/lib
parentdb6efb017f246e2492ccd00613d079de96d8f705 (diff)
downloadbcm5719-llvm-8ee410c75ec416ea02dabeddd03fb062ab5dc92e.tar.gz
bcm5719-llvm-8ee410c75ec416ea02dabeddd03fb062ab5dc92e.zip
[Attributor][MemBehavior] Fallback to the function state for arguments
Even if an argument is captured, we cannot have an effect the function does not have. This is fine except for the special case of `inalloca` as it does not behave by the rules. TODO: Maybe the special rule for `inalloca` is wrong after all. llvm-svn: 374736
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/IPO/Attributor.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index dadf3722a6f..d7c49a248de 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -3838,17 +3838,23 @@ struct AAMemoryBehaviorArgument : AAMemoryBehaviorFloating {
void initialize(Attributor &A) override {
AAMemoryBehaviorFloating::initialize(A);
- // TODO: From readattrs.ll: "inalloca parameters are always
- // considered written"
- if (hasAttr({Attribute::InAlloca}))
- removeAssumedBits(NO_WRITES);
-
// Initialize the use vector with all direct uses of the associated value.
Argument *Arg = getAssociatedArgument();
if (!Arg || !Arg->getParent()->hasExactDefinition())
indicatePessimisticFixpoint();
}
+ ChangeStatus manifest(Attributor &A) override {
+ // TODO: From readattrs.ll: "inalloca parameters are always
+ // considered written"
+ if (hasAttr({Attribute::InAlloca})) {
+ removeKnownBits(NO_WRITES);
+ removeAssumedBits(NO_WRITES);
+ }
+ return AAMemoryBehaviorFloating::manifest(A);
+ }
+
+
/// See AbstractAttribute::trackStatistics()
void trackStatistics() const override {
if (isAssumedReadNone())
@@ -4017,10 +4023,13 @@ ChangeStatus AAMemoryBehaviorFloating::updateImpl(Attributor &A) {
// Make sure the value is not captured (except through "return"), if
// it is, any information derived would be irrelevant anyway as we cannot
- // check the potential aliases introduced by the capture.
+ // check the potential aliases introduced by the capture. However, no need
+ // to fall back to anythign less optimistic than the function state.
const auto &ArgNoCaptureAA = A.getAAFor<AANoCapture>(*this, IRP);
- if (!ArgNoCaptureAA.isAssumedNoCaptureMaybeReturned())
- return indicatePessimisticFixpoint();
+ if (!ArgNoCaptureAA.isAssumedNoCaptureMaybeReturned()) {
+ S.intersectAssumedBits(FnMemAA.getAssumed());
+ return ChangeStatus::CHANGED;
+ }
// The current assumed state used to determine a change.
auto AssumedState = S.getAssumed();
OpenPOWER on IntegriCloud