GithubHelp home page GithubHelp logo

[AliasAnalysis] getModRefInfo(DetachInst *, MemoryLocation &) unnecessarily superlinear time, unnecessarily recursive. about tapir-llvm HOT 3 CLOSED

wsmoses avatar wsmoses commented on June 10, 2024
[AliasAnalysis] getModRefInfo(DetachInst *, MemoryLocation &) unnecessarily superlinear time, unnecessarily recursive.

from tapir-llvm.

Comments (3)

VictorYing avatar VictorYing commented on June 10, 2024

Here's a more recent version that still has the same problem:

ModRefInfo AAResults::getModRefInfo(const DetachInst *D,
const MemoryLocation &Loc) {
ModRefInfo Result = ModRefInfo::NoModRef;
SmallPtrSet<const BasicBlock *, 32> Visited;
SmallVector<const BasicBlock *, 32> WorkList;
WorkList.push_back(D->getDetached());
while (!WorkList.empty()) {
const BasicBlock *BB = WorkList.pop_back_val();
if (!Visited.insert(BB).second)
continue;
for (const Instruction &I : *BB) {
// Ignore sync instructions in this analysis
if (isa<SyncInst>(I))
continue;
// Fail fast if we encounter an invalid CFG.
assert(!(D == &I) &&
"Invalid CFG found: Detached CFG reaches its own Detach.");
Result = unionModRef(Result, getModRefInfo(&I, Loc));
// Early-exit the moment we reach the top of the lattice.
if (isModAndRefSet(Result))
return Result;
}
// Add successors
const Instruction *T = BB->getTerminator();
if (const ReattachInst *RI = dyn_cast<ReattachInst>(T))
if (D->getSyncRegion() == RI->getSyncRegion())
continue;
for (unsigned idx = 0, max = T->getNumSuccessors(); idx < max; ++idx)
WorkList.push_back(T->getSuccessor(idx));
}
return Result;
}

It's that

Result = unionModRef(Result, getModRefInfo(&I, Loc)); 

that causes the problem without any checks for whether this I is itself a detach.

from tapir-llvm.

VictorYing avatar VictorYing commented on June 10, 2024

Elsewhere in the same file, there's a different loop that correctly ignores nested syncs and detaches within a detached CFG:

} else if (auto D = dyn_cast<DetachInst>(I)) {
ModRefInfo Result = ModRefInfo::NoModRef;
SmallPtrSet<BasicBlock *, 32> Visited;
SmallVector<BasicBlock *, 32> WorkList;
WorkList.push_back(D->getDetached());
while (!WorkList.empty()) {
BasicBlock *BB = WorkList.pop_back_val();
if (!Visited.insert(BB).second)
continue;
for (Instruction &DI : *BB) {
// Fail fast if we encounter an invalid CFG.
assert(!(D == &DI) &&
"Detached CFG reaches its own Detach instruction.");
// Ignore sync instructions in this analysis
if (isa<SyncInst>(DI) || isa<DetachInst>(DI))
continue;
if (isa<LoadInst>(DI) || isa<StoreInst>(DI) ||
isa<AtomicCmpXchgInst>(DI) || isa<AtomicRMWInst>(DI) ||
DI.isFenceLike() || ImmutableCallSite(&DI))
Result = unionModRef(Result, getModRefInfo(&DI, Call2));
if (&DI == Call2)
return ModRefInfo::NoModRef;
}
// Add successors
const Instruction *T = BB->getTerminator();
if (const ReattachInst *RI = dyn_cast<ReattachInst>(T))
if (D->getSyncRegion() == RI->getSyncRegion())
continue;
for (unsigned idx = 0, max = T->getNumSuccessors(); idx < max; ++idx)
WorkList.push_back(T->getSuccessor(idx));
}
return Result;

Note the

if (isa<SyncInst>(DI) || isa<DetachInst>(DI))
  continue; 

from tapir-llvm.

VictorYing avatar VictorYing commented on June 10, 2024

Closed by 83765ec

from tapir-llvm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.