[llvm] [SandboxVec][DAG] Build actual dependencies (PR #111094)
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 8 16:22:55 PDT 2024
================
@@ -50,29 +51,136 @@ MemDGNodeIntervalBuilder::make(const Interval<Instruction> &Instrs,
cast<MemDGNode>(DAG.getNode(MemBotI)));
}
+DependencyGraph::DependencyType
+DependencyGraph::getRoughDepType(Instruction *FromI, Instruction *ToI) {
+ // TODO: Perhaps compile-time improvement by skipping if neither is mem?
+ if (FromI->mayWriteToMemory()) {
+ if (ToI->mayReadFromMemory())
+ return DependencyType::RAW;
+ if (ToI->mayWriteToMemory())
+ return DependencyType::WAW;
+ } else if (FromI->mayReadFromMemory()) {
+ if (ToI->mayWriteToMemory())
+ return DependencyType::WAR;
+ if (ToI->mayReadFromMemory())
+ return DependencyType::RAR;
+ }
+ if (isa<sandboxir::PHINode>(FromI) || isa<sandboxir::PHINode>(ToI))
+ return DependencyType::CTRL;
+ if (ToI->isTerminator())
+ return DependencyType::CTRL;
+ if (DGNode::isStackSaveOrRestoreIntrinsic(FromI) ||
+ DGNode::isStackSaveOrRestoreIntrinsic(ToI))
+ return DependencyType::OTHER;
+ return DependencyType::NONE;
+}
+
+static bool isOrdered(Instruction *I) {
+ auto IsOrdered = [](Instruction *I) {
+ if (auto *LI = dyn_cast<LoadInst>(I))
+ return !LI->isUnordered();
+ if (auto *SI = dyn_cast<StoreInst>(I))
+ return !SI->isUnordered();
+ if (DGNode::isFenceLike(I))
+ return true;
+ return false;
+ };
+ bool Is = IsOrdered(I);
+ assert((!Is || DGNode::isMemDepCandidate(I)) &&
+ "An ordered instruction must be a MemDepCandidate!");
+ return Is;
+}
+
+bool DependencyGraph::alias(Instruction *SrcI, Instruction *DstI,
+ DependencyType DepType) {
+ std::optional<MemoryLocation> DstLocOpt =
+ Utils::memoryLocationGetOrNone(DstI);
+ if (!DstLocOpt)
+ return true;
+ // Check aliasing.
+ assert((SrcI->mayReadFromMemory() || SrcI->mayWriteToMemory()) &&
+ "Expected a mem instr");
+ // TODO: Check AABudget
+ ModRefInfo SrcModRef =
+ isOrdered(SrcI)
+ ? ModRefInfo::Mod
----------------
aeubanks wrote:
be conservative with `ModRef`?
https://github.com/llvm/llvm-project/pull/111094
More information about the llvm-commits
mailing list