mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-14 07:31:47 +00:00
[attrs] Simplify the convergent removal to directly use the pre-built
node set rather than walking the SCC directly. This directly exposes the functions and has already had null entries filtered out. We also don't need need to handle optnone as it has already been handled in the caller -- we never try to remove convergent when there are optnone functions in the SCC. With this change, the code for removing convergent should work with the new pass manager and a different SCC analysis. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@260668 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3f89873441
commit
5403bca6ae
@ -938,16 +938,11 @@ static bool addNonNullAttrs(const SCCNodeSet &SCCNodes,
|
|||||||
/// Removes convergent attributes where we can prove that none of the SCC's
|
/// Removes convergent attributes where we can prove that none of the SCC's
|
||||||
/// callees are themselves convergent. Returns true if successful at removing
|
/// callees are themselves convergent. Returns true if successful at removing
|
||||||
/// the attribute.
|
/// the attribute.
|
||||||
static bool removeConvergentAttrs(const CallGraphSCC &SCC,
|
static bool removeConvergentAttrs(const SCCNodeSet &SCCNodes) {
|
||||||
const SCCNodeSet &SCCNodes) {
|
|
||||||
// Determines whether a function can be made non-convergent, ignoring all
|
// Determines whether a function can be made non-convergent, ignoring all
|
||||||
// other functions in SCC. (A function can *actually* be made non-convergent
|
// other functions in SCC. (A function can *actually* be made non-convergent
|
||||||
// only if all functions in its SCC can be made convergent.)
|
// only if all functions in its SCC can be made convergent.)
|
||||||
auto CanRemoveConvergent = [&](CallGraphNode *CGN) {
|
auto CanRemoveConvergent = [&](Function *F) {
|
||||||
Function *F = CGN->getFunction();
|
|
||||||
if (!F)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!F->isConvergent())
|
if (!F->isConvergent())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -955,10 +950,6 @@ static bool removeConvergentAttrs(const CallGraphSCC &SCC,
|
|||||||
if (F->isDeclaration())
|
if (F->isDeclaration())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Don't remove convergent from optnone functions.
|
|
||||||
if (F->hasFnAttribute(Attribute::OptimizeNone))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
for (Instruction &I : instructions(*F))
|
for (Instruction &I : instructions(*F))
|
||||||
if (auto CS = CallSite(&I)) {
|
if (auto CS = CallSite(&I)) {
|
||||||
// Can't remove convergent if any of F's callees -- ignoring functions
|
// Can't remove convergent if any of F's callees -- ignoring functions
|
||||||
@ -979,19 +970,16 @@ static bool removeConvergentAttrs(const CallGraphSCC &SCC,
|
|||||||
// We can remove the convergent attr from functions in the SCC if they all
|
// We can remove the convergent attr from functions in the SCC if they all
|
||||||
// can be made non-convergent (because they call only non-convergent
|
// can be made non-convergent (because they call only non-convergent
|
||||||
// functions, other than each other).
|
// functions, other than each other).
|
||||||
if (!llvm::all_of(SCC, CanRemoveConvergent))
|
if (!llvm::all_of(SCCNodes, CanRemoveConvergent))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// If we got here, all of the SCC's callees are non-convergent, and none of
|
// If we got here, all of the SCC's callees are non-convergent. Therefore all
|
||||||
// the optnone functions in the SCC are marked as convergent. Therefore all
|
|
||||||
// of the SCC's functions can be marked as non-convergent.
|
// of the SCC's functions can be marked as non-convergent.
|
||||||
for (CallGraphNode *CGN : SCC)
|
for (Function *F : SCCNodes) {
|
||||||
if (Function *F = CGN->getFunction()) {
|
if (F->isConvergent())
|
||||||
if (F->isConvergent())
|
DEBUG(dbgs() << "Removing convergent attr from " << F->getName() << "\n");
|
||||||
DEBUG(dbgs() << "Removing convergent attr from " << F->getName()
|
F->setNotConvergent();
|
||||||
<< "\n");
|
}
|
||||||
F->setNotConvergent();
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1071,7 +1059,7 @@ bool PostOrderFunctionAttrs::runOnSCC(CallGraphSCC &SCC) {
|
|||||||
if (!ExternalNode) {
|
if (!ExternalNode) {
|
||||||
Changed |= addNoAliasAttrs(SCCNodes);
|
Changed |= addNoAliasAttrs(SCCNodes);
|
||||||
Changed |= addNonNullAttrs(SCCNodes, *TLI);
|
Changed |= addNonNullAttrs(SCCNodes, *TLI);
|
||||||
Changed |= removeConvergentAttrs(SCC, SCCNodes);
|
Changed |= removeConvergentAttrs(SCCNodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
Changed |= addNoRecurseAttrs(SCC);
|
Changed |= addNoRecurseAttrs(SCC);
|
||||||
|
Loading…
Reference in New Issue
Block a user