From 90f0a8494347a3e5df82f4905338c6917fd97452 Mon Sep 17 00:00:00 2001 From: Diana Picus Date: Tue, 15 Nov 2016 15:38:15 +0000 Subject: [PATCH] [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. llvm-svn: 286974 --- llvm/lib/Target/ARM/ARMTargetMachine.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/llvm/lib/Target/ARM/ARMTargetMachine.cpp b/llvm/lib/Target/ARM/ARMTargetMachine.cpp index 355a499..d7d7a0e 100644 --- a/llvm/lib/Target/ARM/ARMTargetMachine.cpp +++ b/llvm/lib/Target/ARM/ARMTargetMachine.cpp @@ -294,25 +294,25 @@ ARMBaseTargetMachine::getSubtargetImpl(const Function &F) const { // function that reside in TargetOptions. resetTargetOptions(F); I = llvm::make_unique(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(); } -- 2.7.4