diff options
author | Nuno Lopes <nunoplopes@sapo.pt> | 2008-11-04 23:03:58 +0000 |
---|---|---|
committer | Nuno Lopes <nunoplopes@sapo.pt> | 2008-11-04 23:03:58 +0000 |
commit | 641397f2ef0a155159e1085bf594c1535485e3a3 (patch) | |
tree | 155e99e8e66a3c25af0577bb5ad1a59c89aaf51a /tools/opt | |
parent | 879b1ac22e6307e3111eac87bfba123fba1ac7a4 (diff) | |
download | external_llvm-641397f2ef0a155159e1085bf594c1535485e3a3.zip external_llvm-641397f2ef0a155159e1085bf594c1535485e3a3.tar.gz external_llvm-641397f2ef0a155159e1085bf594c1535485e3a3.tar.bz2 |
fix memory leak in pass manager when adding an analysis pass that already existed. as pass manager takes ownership of the added passes, it has to delete the pass if it isnt added to the pass list
tweak the opt tool so that it doesnt access a Pass after the ownership was taken by the pass manager
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58730 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/opt')
-rw-r--r-- | tools/opt/opt.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp index a339d31..b0077ea 100644 --- a/tools/opt/opt.cpp +++ b/tools/opt/opt.cpp @@ -527,16 +527,21 @@ int main(int argc, char **argv) { cerr << argv[0] << ": cannot create pass: " << PassInf->getPassName() << "\n"; if (P) { + bool isBBPass = dynamic_cast<BasicBlockPass*>(P) != 0; + bool isLPass = !isBBPass && dynamic_cast<LoopPass*>(P) != 0; + bool isFPass = !isLPass && dynamic_cast<FunctionPass*>(P) != 0; + bool isCGSCCPass = !isFPass && dynamic_cast<CallGraphSCCPass*>(P) != 0; + addPass(Passes, P); - + if (AnalyzeOnly) { - if (dynamic_cast<BasicBlockPass*>(P)) + if (isBBPass) Passes.add(new BasicBlockPassPrinter(PassInf)); - else if (dynamic_cast<LoopPass*>(P)) - Passes.add(new LoopPassPrinter(PassInf)); - else if (dynamic_cast<FunctionPass*>(P)) + else if (isLPass) + Passes.add(new LoopPassPrinter(PassInf)); + else if (isFPass) Passes.add(new FunctionPassPrinter(PassInf)); - else if (dynamic_cast<CallGraphSCCPass*>(P)) + else if (isCGSCCPass) Passes.add(new CallGraphSCCPassPrinter(PassInf)); else Passes.add(new ModulePassPrinter(PassInf)); |