]> granicus.if.org Git - llvm/commitdiff
[llc] Do not create the pass config several times for run-pass.
authorQuentin Colombet <qcolombet@apple.com>
Fri, 10 Jun 2016 01:12:06 +0000 (01:12 +0000)
committerQuentin Colombet <qcolombet@apple.com>
Fri, 10 Jun 2016 01:12:06 +0000 (01:12 +0000)
Thanks to Matthias Braun for spotting this.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272358 91177308-0d34-0410-b5e6-96231b3b80d8

tools/llc/llc.cpp

index 51ce3c0f2bf10173c8b1b9b8d94bf457806b2b95..6d24204b19377964428ae461015924c7f0f76613 100644 (file)
@@ -411,18 +411,19 @@ static int compileModule(char **argv, LLVMContext &Context) {
         errs() << argv[0] << ": run-pass needs a .mir input.\n";
         return 1;
       }
+      LLVMTargetMachine &LLVMTM = static_cast<LLVMTargetMachine&>(*Target);
+      TargetPassConfig *TPC = LLVMTM.createPassConfig(PM);
+      PM.add(TPC);
+      LLVMTM.addMachineModuleInfo(PM);
+      LLVMTM.addMachineFunctionAnalysis(PM, MIR.get());
+      TPC->printAndVerify("");
+
       for (std::string &RunPassName : *RunPassNames) {
         const PassInfo *PI = PR->getPassInfo(RunPassName);
         if (!PI) {
           errs() << argv[0] << ": run-pass " << RunPassName << " is not registered.\n";
           return 1;
         }
-        LLVMTargetMachine &LLVMTM = static_cast<LLVMTargetMachine&>(*Target);
-        TargetPassConfig *TPC = LLVMTM.createPassConfig(PM);
-        PM.add(TPC);
-        LLVMTM.addMachineModuleInfo(PM);
-        LLVMTM.addMachineFunctionAnalysis(PM, MIR.get());
-        TPC->printAndVerify("");
 
         Pass *P;
         if (PI->getTargetMachineCtor())