Skip to content

Commit

Permalink
[FastISel] Propagate PCSections metadata to MachineInstr
Browse files Browse the repository at this point in the history
Propagate PC sections metadata to MachineInstr when FastISel is doing
instruction selection.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D130884
  • Loading branch information
melver committed Sep 7, 2022
1 parent 98a3a34 commit 0ba8886
Show file tree
Hide file tree
Showing 9 changed files with 394 additions and 393 deletions.
5 changes: 3 additions & 2 deletions llvm/include/llvm/CodeGen/FastISel.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/TargetLowering.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/CallingConv.h"
Expand Down Expand Up @@ -204,7 +205,7 @@ class FastISel {
MachineRegisterInfo &MRI;
MachineFrameInfo &MFI;
MachineConstantPool &MCP;
DebugLoc DbgLoc;
MIMetadata MIMD;
const TargetMachine &TM;
const DataLayout &DL;
const TargetInstrInfo &TII;
Expand Down Expand Up @@ -247,7 +248,7 @@ class FastISel {
void finishBasicBlock();

/// Return current debug location information.
DebugLoc getCurDebugLoc() const { return DbgLoc; }
DebugLoc getCurDebugLoc() const { return MIMD.getDL(); }

/// Do "fast" instruction selection for function arguments and append
/// the machine instructions to the current block. Returns true when
Expand Down
108 changes: 54 additions & 54 deletions llvm/lib/CodeGen/SelectionDAG/FastISel.cpp

Large diffs are not rendered by default.

142 changes: 71 additions & 71 deletions llvm/lib/Target/AArch64/AArch64FastISel.cpp

Large diffs are not rendered by default.

142 changes: 71 additions & 71 deletions llvm/lib/Target/ARM/ARMFastISel.cpp

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions llvm/lib/Target/Mips/MipsFastISel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,11 @@ class MipsFastISel final : public FastISel {
unsigned materializeExternalCallSym(MCSymbol *Syn);

MachineInstrBuilder emitInst(unsigned Opc) {
return BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(Opc));
return BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD, TII.get(Opc));
}

MachineInstrBuilder emitInst(unsigned Opc, unsigned DstReg) {
return BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(Opc),
return BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD, TII.get(Opc),
DstReg);
}

Expand Down Expand Up @@ -338,7 +338,7 @@ unsigned MipsFastISel::fastMaterializeAlloca(const AllocaInst *AI) {

if (SI != FuncInfo.StaticAllocaMap.end()) {
Register ResultReg = createResultReg(&Mips::GPR32RegClass);
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(Mips::LEA_ADDiu),
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD, TII.get(Mips::LEA_ADDiu),
ResultReg)
.addFrameIndex(SI->second)
.addImm(0);
Expand Down Expand Up @@ -794,7 +794,7 @@ bool MipsFastISel::emitLoad(MVT VT, unsigned &ResultReg, Address &Addr) {
MachineMemOperand *MMO = MF->getMachineMemOperand(
MachinePointerInfo::getFixedStack(*MF, FI), MachineMemOperand::MOLoad,
MFI.getObjectSize(FI), Align(4));
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(Opc), ResultReg)
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD, TII.get(Opc), ResultReg)
.addFrameIndex(FI)
.addImm(Offset)
.addMemOperand(MMO);
Expand Down Expand Up @@ -843,7 +843,7 @@ bool MipsFastISel::emitStore(MVT VT, unsigned SrcReg, Address &Addr) {
MachineMemOperand *MMO = MF->getMachineMemOperand(
MachinePointerInfo::getFixedStack(*MF, FI), MachineMemOperand::MOStore,
MFI.getObjectSize(FI), Align(4));
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(Opc))
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD, TII.get(Opc))
.addReg(SrcReg)
.addFrameIndex(FI)
.addImm(Offset)
Expand Down Expand Up @@ -967,7 +967,7 @@ bool MipsFastISel::selectBranch(const Instruction *I) {
return false;
}

BuildMI(*BrBB, FuncInfo.InsertPt, DbgLoc, TII.get(Mips::BGTZ))
BuildMI(*BrBB, FuncInfo.InsertPt, MIMD, TII.get(Mips::BGTZ))
.addReg(ZExtCondReg)
.addMBB(TBB);
finishCondBranch(BI->getParent(), TBB, FBB);
Expand Down Expand Up @@ -1221,7 +1221,7 @@ bool MipsFastISel::processCallArgs(CallLoweringInfo &CLI,

// Now copy/store arg to correct locations.
if (VA.isRegLoc() && !VA.needsCustom()) {
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
TII.get(TargetOpcode::COPY), VA.getLocReg()).addReg(ArgReg);
CLI.OutRegs.push_back(VA.getLocReg());
} else if (VA.needsCustom()) {
Expand Down Expand Up @@ -1291,7 +1291,7 @@ bool MipsFastISel::finishCall(CallLoweringInfo &CLI, MVT RetVT,
Register ResultReg = createResultReg(TLI.getRegClassFor(CopyVT));
if (!ResultReg)
return false;
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
TII.get(TargetOpcode::COPY),
ResultReg).addReg(RVLocs[0].getLocReg());
CLI.InRegs.push_back(RVLocs[0].getLocReg());
Expand Down Expand Up @@ -1461,7 +1461,7 @@ bool MipsFastISel::fastLowerArguments() {
// Without this, EmitLiveInCopies may eliminate the livein if its only
// use is a bitcast (which isn't turned into an instruction).
Register ResultReg = createResultReg(Allocation[ArgNo].RC);
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
TII.get(TargetOpcode::COPY), ResultReg)
.addReg(DstReg, getKillRegState(true));
updateValueMap(&FormalArg, ResultReg);
Expand Down Expand Up @@ -1550,7 +1550,7 @@ bool MipsFastISel::fastLowerCall(CallLoweringInfo &CLI) {
DestAddress = materializeGV(Addr.getGlobalValue(), MVT::i32);
emitInst(TargetOpcode::COPY, Mips::T9).addReg(DestAddress);
MachineInstrBuilder MIB =
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(Mips::JALR),
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD, TII.get(Mips::JALR),
Mips::RA).addReg(Mips::T9);

// Add implicit physical register uses to the call.
Expand Down Expand Up @@ -1756,7 +1756,7 @@ bool MipsFastISel::selectRet(const Instruction *I) {
}

// Make the copy.
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
TII.get(TargetOpcode::COPY), DestReg).addReg(SrcReg);

// Add register to return instruction.
Expand Down Expand Up @@ -2127,7 +2127,7 @@ unsigned MipsFastISel::fastEmitInst_rr(unsigned MachineInstOpcode,
const MCInstrDesc &II = TII.get(MachineInstOpcode);
Op0 = constrainOperandRegClass(II, Op0, II.getNumDefs());
Op1 = constrainOperandRegClass(II, Op1, II.getNumDefs() + 1);
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II, ResultReg)
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD, II, ResultReg)
.addReg(Op0)
.addReg(Op1)
.addReg(Mips::HI0, RegState::ImplicitDefine | RegState::Dead)
Expand Down
Loading

0 comments on commit 0ba8886

Please sign in to comment.