[llvm] 214ed3f - [Attributor] Record dependences only when necessary
Johannes Doerfert via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 23 16:43:40 PST 2020
Author: Johannes Doerfert
Date: 2020-01-23T18:42:45-06:00
New Revision: 214ed3f676d2a1f0329c8dd4b3a0d4218f2b96cb
URL: https://github.com/llvm/llvm-project/commit/214ed3f676d2a1f0329c8dd4b3a0d4218f2b96cb
DIFF: https://github.com/llvm/llvm-project/commit/214ed3f676d2a1f0329c8dd4b3a0d4218f2b96cb.diff
LOG: [Attributor] Record dependences only when necessary
If we use assumed information from AAValueSimplify we need to record
an OPTIONAL dependence, otherwise we do not.
Added:
Modified:
llvm/lib/Transforms/IPO/Attributor.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index 648dc8f2ba18..a7e9c5ddaa16 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -255,6 +255,28 @@ static void replaceAllInstructionUsesWith(Value &Old, Value &New) {
U->set(&New);
}
+static Optional<ConstantInt *>
+getAssumedConstant(Attributor &A, const Value &V, const AbstractAttribute &AA,
+ bool &UsedAssumedInformation) {
+ const auto &ValueSimplifyAA = A.getAAFor<AAValueSimplify>(
+ AA, IRPosition::value(V), /* TrackDependence */ false);
+ Optional<Value *> SimplifiedV = ValueSimplifyAA.getAssumedSimplifiedValue(A);
+ bool IsKnown = ValueSimplifyAA.isKnown();
+ UsedAssumedInformation |= !IsKnown;
+ if (!SimplifiedV.hasValue()) {
+ A.recordDependence(ValueSimplifyAA, AA, DepClassTy::OPTIONAL);
+ return llvm::None;
+ }
+ if (isa_and_nonnull<UndefValue>(SimplifiedV.getValue())) {
+ A.recordDependence(ValueSimplifyAA, AA, DepClassTy::OPTIONAL);
+ return llvm::None;
+ }
+ ConstantInt *CI = dyn_cast_or_null<ConstantInt>(SimplifiedV.getValue());
+ if (CI)
+ A.recordDependence(ValueSimplifyAA, AA, DepClassTy::OPTIONAL);
+ return CI;
+}
+
/// Recursively visit all values that might become \p IRP at some point. This
/// will be done by looking through cast instructions, selects, phis, and calls
/// with the "returned" attribute. Once we cannot look through the value any
@@ -2980,20 +3002,6 @@ identifyAliveSuccessors(Attributor &A, const InvokeInst &II,
return UsedAssumedInformation;
}
-static Optional<ConstantInt *>
-getAssumedConstant(Attributor &A, const Value &V, AbstractAttribute &AA,
- bool &UsedAssumedInformation) {
- const auto &ValueSimplifyAA =
- A.getAAFor<AAValueSimplify>(AA, IRPosition::value(V));
- Optional<Value *> SimplifiedV = ValueSimplifyAA.getAssumedSimplifiedValue(A);
- UsedAssumedInformation |= !ValueSimplifyAA.isKnown();
- if (!SimplifiedV.hasValue())
- return llvm::None;
- if (isa_and_nonnull<UndefValue>(SimplifiedV.getValue()))
- return llvm::None;
- return dyn_cast_or_null<ConstantInt>(SimplifiedV.getValue());
-}
-
static bool
identifyAliveSuccessors(Attributor &A, const BranchInst &BI,
AbstractAttribute &AA,
More information about the llvm-commits
mailing list