[PATCH] D33222: [LegacyPassManager] Remove TargetMachine constructors

Eric Christopher via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 17 15:59:19 PDT 2017


echristo accepted this revision.
echristo added a comment.

This LGTM. I'd get one from Chandler as well though.



================
Comment at: lib/Target/Mips/MipsModuleISelDAGToDAG.cpp:40-41
   DEBUG(errs() << "In MipsModuleDAGToDAGISel::runMachineFunction\n");
+  auto &TM = const_cast<MipsTargetMachine &>(
+      static_cast<const MipsTargetMachine &>(MF.getTarget()));
   TM.resetSubtarget(&MF);
----------------
chandlerc wrote:
> This is horrible. =/
> 
> I think the `MipsTargetMachine` should directly expose a const-qualified `resetSubtarget` method, as it is already doing crazy const-casting... Or it should have some other way of doing this.
> 
> I might just leave the original code for this part of the Mips backend rather than trying to make it clean in the same way.
The mips target just needs to remove their subtarget like arm, aarch64, ppc, and x86.


================
Comment at: lib/Target/Mips/MipsModuleISelDAGToDAG.cpp:46
   DEBUG(errs() << "In MipsModuleDAGToDAGISel::runMachineFunction\n");
+  auto& TPC = getAnalysis<TargetPassConfig>();
+  auto &TM = TPC.getTM<MipsTargetMachine>();
----------------
Formatting nit.


https://reviews.llvm.org/D33222





More information about the llvm-commits mailing list