[llvm] 60990d9 - [BasicAA] Move experimental.guard modelling to getModRefBehavior()
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 22 07:51:24 PDT 2022
Author: Nikita Popov
Date: 2022-09-22T16:48:51+02:00
New Revision: 60990d9042b9668001bcfa095b970558fc63e5a9
URL: https://github.com/llvm/llvm-project/commit/60990d9042b9668001bcfa095b970558fc63e5a9
DIFF: https://github.com/llvm/llvm-project/commit/60990d9042b9668001bcfa095b970558fc63e5a9.diff
LOG: [BasicAA] Move experimental.guard modelling to getModRefBehavior()
While we can't express this with attributes yet, we can model
these intrinsics as readonly + writing inaccessible memory (for
the control dependence) in FMRB. This way we don't need to
special-case them in getModRefInfo(), it falls out of the usual
logic.
Added:
Modified:
llvm/lib/Analysis/BasicAliasAnalysis.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
index c0e373f38b42..0641342b1945 100644
--- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -790,6 +790,15 @@ FunctionModRefBehavior BasicAAResult::getModRefBehavior(const Function *F) {
if (F->doesNotAccessMemory())
return FunctionModRefBehavior::none();
+ switch (F->getIntrinsicID()) {
+ case Intrinsic::experimental_guard:
+ case Intrinsic::experimental_deoptimize:
+ // These intrinsics can read arbitrary memory, and additionally modref
+ // inaccessible memory to model control dependence.
+ return FunctionModRefBehavior::readOnly() |
+ FunctionModRefBehavior::inaccessibleMemOnly(ModRefInfo::ModRef);
+ }
+
// If the function declares it only reads memory, go with that.
ModRefInfo MR = ModRefInfo::ModRef;
if (F->onlyReadsMemory())
@@ -980,19 +989,6 @@ ModRefInfo BasicAAResult::getModRefInfo(const CallBase *Call,
return ModRefInfo::NoModRef;
}
- // Guard intrinsics are marked as arbitrarily writing so that proper control
- // dependencies are maintained but they never mods any particular memory
- // location.
- //
- // *Unlike* assumes, guard intrinsics are modeled as reading memory since the
- // heap state at the point the guard is issued needs to be consistent in case
- // the guard invokes the "deopt" continuation.
- if (isIntrinsicCall(Call, Intrinsic::experimental_guard))
- return ModRefInfo::Ref;
- // The same applies to deoptimize which is essentially a guard(false).
- if (isIntrinsicCall(Call, Intrinsic::experimental_deoptimize))
- return ModRefInfo::Ref;
-
// Like assumes, invariant.start intrinsics were also marked as arbitrarily
// writing so that proper control dependencies are maintained but they never
// mod any particular memory location visible to the IR.
More information about the llvm-commits
mailing list