[llvm] r286974 - [ARM] Make sure GlobalISel is only initialized once. NFCI

Diana Picus via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 15 07:38:16 PST 2016


Author: rovka
Date: Tue Nov 15 09:38:15 2016
New Revision: 286974

URL: http://llvm.org/viewvc/llvm-project?rev=286974&view=rev
Log:
[ARM] Make sure GlobalISel is only initialized once. NFCI

Move some code inside the proper 'if' block to make sure it is only run once,
when the subtarget is first created. Things can still break if we use different
ARM target machines or if we have functions with different 'target-cpu' or
'target-features', we should fix that too in the future.

Modified:
    llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp

Modified: llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp?rev=286974&r1=286973&r2=286974&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp Tue Nov 15 09:38:15 2016
@@ -294,25 +294,25 @@ ARMBaseTargetMachine::getSubtargetImpl(c
     // function that reside in TargetOptions.
     resetTargetOptions(F);
     I = llvm::make_unique<ARMSubtarget>(TargetTriple, CPU, FS, *this, isLittle);
-  }
 
 #ifndef LLVM_BUILD_GLOBAL_ISEL
-  GISelAccessor *GISel = new GISelAccessor();
+    GISelAccessor *GISel = new GISelAccessor();
 #else
-  ARMGISelActualAccessor *GISel = new ARMGISelActualAccessor();
-  GISel->CallLoweringInfo.reset(new ARMCallLowering(*I->getTargetLowering()));
-  GISel->Legalizer.reset(new ARMLegalizerInfo());
+    ARMGISelActualAccessor *GISel = new ARMGISelActualAccessor();
+    GISel->CallLoweringInfo.reset(new ARMCallLowering(*I->getTargetLowering()));
+    GISel->Legalizer.reset(new ARMLegalizerInfo());
 
-  auto *RBI = new ARMRegisterBankInfo(*I->getRegisterInfo());
+    auto *RBI = new ARMRegisterBankInfo(*I->getRegisterInfo());
 
-  // FIXME: At this point, we can't rely on Subtarget having RBI.
-  // It's awkward to mix passing RBI and the Subtarget; should we pass
-  // TII/TRI as well?
-  GISel->InstSelector.reset(new ARMInstructionSelector(*this, *I, *RBI));
+    // FIXME: At this point, we can't rely on Subtarget having RBI.
+    // It's awkward to mix passing RBI and the Subtarget; should we pass
+    // TII/TRI as well?
+    GISel->InstSelector.reset(new ARMInstructionSelector(*this, *I, *RBI));
 
-  GISel->RegBankInfo.reset(RBI);
+    GISel->RegBankInfo.reset(RBI);
 #endif
-  I->setGISelAccessor(*GISel);
+    I->setGISelAccessor(*GISel);
+  }
   return I.get();
 }
 




More information about the llvm-commits mailing list