[PATCH] D56768: Solution for opt's crash bug caused by "-early-cse-memssa -early-cse-memssa"
ZhiDe Zhou via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 15 18:26:38 PST 2019
cszide created this revision.
cszide added reviewers: chandlerc, jcranmer.
Herald added subscribers: llvm-commits, Prazek, mehdi_amini.
The optimization sequence "-early-cse-memssa -early-cse-memssa" will cause a crash bug for opt tool with any input. This is because that the LegacyPassManager can not correctly process the dependency of the second "-early-cse-memssa".
The "-early-cse-memssa" pass requires analysis pass "Memory SSA" and will preserves it. However, the "-early-cse-memssa" pass can not preserve pass "Function Alias Analysis Results", which is required by pass "Memory SSA" and it will be removed after the first "-early-cse-memssa". Thus, when adding the second "-early-cse-memssa", the LegacyPassManager find that the analysis pass "Memory SSA" is already existed, which causes that the required pass "Function Alias Analysis Results" can not be satisfied for the second "-early-cse-memssa".
PS: This bug has been verified using llvm 6/7 and the truck version.
Repository:
rL LLVM
https://reviews.llvm.org/D56768
Files:
lib/IR/LegacyPassManager.cpp
Index: lib/IR/LegacyPassManager.cpp
===================================================================
--- lib/IR/LegacyPassManager.cpp
+++ lib/IR/LegacyPassManager.cpp
@@ -731,6 +731,53 @@
// passes are run on the fly.
delete AnalysisPass;
}
+ else{
+ AnalysisUsage *TrAnUsage = findAnalysisUsage(AnalysisPass);
+ const AnalysisUsage::VectorType &TrIDs = TrAnUsage->getRequiredTransitiveSet();
+ for (AnalysisID ID : TrIDs) {
+ Pass *TrAP = findAnalysisPass(ID);
+ if(!TrAP){
+ const PassInfo *PI = findAnalysisPassInfo(ID);
+
+ if (!PI) {
+ // Pass P is not in the global PassRegistry
+ dbgs() << "Pass '" << P->getPassName() << "' is not initialized." << "\n";
+ dbgs() << "Verify if there is a pass dependency cycle." << "\n";
+ dbgs() << "Required Passes:" << "\n";
+ for (const AnalysisID ID2 : RequiredSet) {
+ if (ID == ID2)
+ break;
+ Pass *AnalysisPass2 = findAnalysisPass(ID2);
+ if (AnalysisPass2) {
+ dbgs() << "\t" << AnalysisPass2->getPassName() << "\n";
+ } else {
+ dbgs() << "\t" << "Error: Required pass not found! Possible causes:" << "\n";
+ dbgs() << "\t\t" << "- Pass misconfiguration (e.g.: missing macros)" << "\n";
+ dbgs() << "\t\t" << "- Corruption of the global PassRegistry" << "\n";
+ }
+ }
+ }
+
+ assert(PI && "Expected required passes to be initialized");
+ AnalysisPass = PI->createPass();
+ if (P->getPotentialPassManagerType () ==
+ AnalysisPass->getPotentialPassManagerType())
+ // Schedule analysis pass that is managed by the same pass manager.
+ schedulePass(AnalysisPass);
+ else if (P->getPotentialPassManagerType () >
+ AnalysisPass->getPotentialPassManagerType()) {
+ // Schedule analysis pass that is managed by a new manager.
+ schedulePass(AnalysisPass);
+ // Recheck analysis passes to ensure that required analyses that
+ // are already checked are still available.
+ checkAnalysis = true;
+ } else
+ // Do not schedule this analysis. Lower level analysis
+ // passes are run on the fly.
+ delete AnalysisPass;
+ }
+ }
+ }
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56768.181952.patch
Type: text/x-patch
Size: 2580 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190116/56fc1618/attachment.bin>
More information about the llvm-commits
mailing list