Skip to content

Commit 1e413ff

Browse files
committedApr 24, 2019
[Mips][CodeGen] Remove MachineFunction::setSubtarget. Change Mips to just copy the subtarget from the MachineFunction instead of recalculating it.
Summary: The MachineFunction should have been created with the correct subtarget. As long as there is no way to change it, MipsTargetMachine can just capture it directly from the MachineFunction without calling getSubtargetImpl again. While there, const correct the Subtarget pointer to avoid a const_cast. I believe the Mips16Subtarget and NoMips16Subtarget members are never used, but I'll leave there removal for a separate patch. Reviewers: echristo, atanasyan Reviewed By: atanasyan Subscribers: sdardis, arichardson, hiraditya, jrtc27, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D60936 llvm-svn: 359071
1 parent 7478085 commit 1e413ff

File tree

3 files changed

+2
-4
lines changed

3 files changed

+2
-4
lines changed
 

‎llvm/include/llvm/CodeGen/MachineFunction.h

-1
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,6 @@ class MachineFunction {
439439
/// getSubtarget - Return the subtarget for which this machine code is being
440440
/// compiled.
441441
const TargetSubtargetInfo &getSubtarget() const { return *STI; }
442-
void setSubtarget(const TargetSubtargetInfo *ST) { STI = ST; }
443442

444443
/// getSubtarget - This method returns a pointer to the specified type of
445444
/// TargetSubtargetInfo. In debug builds, it verifies that the object being

‎llvm/lib/Target/Mips/MipsTargetMachine.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,7 @@ MipsTargetMachine::getSubtargetImpl(const Function &F) const {
204204
void MipsTargetMachine::resetSubtarget(MachineFunction *MF) {
205205
LLVM_DEBUG(dbgs() << "resetSubtarget\n");
206206

207-
Subtarget = const_cast<MipsSubtarget *>(getSubtargetImpl(MF->getFunction()));
208-
MF->setSubtarget(Subtarget);
207+
Subtarget = &MF->getSubtarget<MipsSubtarget>();
209208
}
210209

211210
namespace {

‎llvm/lib/Target/Mips/MipsTargetMachine.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class MipsTargetMachine : public LLVMTargetMachine {
2929
std::unique_ptr<TargetLoweringObjectFile> TLOF;
3030
// Selected ABI
3131
MipsABIInfo ABI;
32-
MipsSubtarget *Subtarget;
32+
const MipsSubtarget *Subtarget;
3333
MipsSubtarget DefaultSubtarget;
3434
MipsSubtarget NoMips16Subtarget;
3535
MipsSubtarget Mips16Subtarget;

0 commit comments

Comments
 (0)