mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
Sink DI metadata usage out of MachineInstr.h and MachineInstrBuilder.h
MachineInstr.h and MachineInstrBuilder.h are very popular headers, widely included across all LLVM backends. It turns out that there only a handful of TUs that actually care about DI operands on MachineInstrs. After this change, touching DebugInfoMetadata.h and rebuilding llc only needs 112 actions instead of 542. llvm-svn: 266351
This commit is contained in:
parent
8301c52067
commit
2c00bf1830
@ -25,7 +25,6 @@
|
||||
#include "llvm/ADT/iterator_range.h"
|
||||
#include "llvm/Analysis/AliasAnalysis.h"
|
||||
#include "llvm/CodeGen/MachineOperand.h"
|
||||
#include "llvm/IR/DebugInfo.h"
|
||||
#include "llvm/IR/DebugLoc.h"
|
||||
#include "llvm/IR/InlineAsm.h"
|
||||
#include "llvm/MC/MCInstrDesc.h"
|
||||
@ -35,6 +34,8 @@
|
||||
namespace llvm {
|
||||
|
||||
template <typename T> class SmallVectorImpl;
|
||||
class DILocalVariable;
|
||||
class DIExpression;
|
||||
class TargetInstrInfo;
|
||||
class TargetRegisterClass;
|
||||
class TargetRegisterInfo;
|
||||
@ -263,17 +264,11 @@ public:
|
||||
|
||||
/// Return the debug variable referenced by
|
||||
/// this DBG_VALUE instruction.
|
||||
const DILocalVariable *getDebugVariable() const {
|
||||
assert(isDebugValue() && "not a DBG_VALUE");
|
||||
return cast<DILocalVariable>(getOperand(2).getMetadata());
|
||||
}
|
||||
const DILocalVariable *getDebugVariable() const;
|
||||
|
||||
/// Return the complex address expression referenced by
|
||||
/// this DBG_VALUE instruction.
|
||||
const DIExpression *getDebugExpression() const {
|
||||
assert(isDebugValue() && "not a DBG_VALUE");
|
||||
return cast<DIExpression>(getOperand(3).getMetadata());
|
||||
}
|
||||
const DIExpression *getDebugExpression() const;
|
||||
|
||||
/// Emit an error referring to the source location of this instruction.
|
||||
/// This should only be used for inline assembly that is somehow
|
||||
|
@ -350,47 +350,19 @@ inline MachineInstrBuilder BuildMI(MachineBasicBlock *BB,
|
||||
/// for either a value in a register or a register-indirect+offset
|
||||
/// address. The convention is that a DBG_VALUE is indirect iff the
|
||||
/// second operand is an immediate.
|
||||
inline MachineInstrBuilder BuildMI(MachineFunction &MF, DebugLoc DL,
|
||||
const MCInstrDesc &MCID, bool IsIndirect,
|
||||
unsigned Reg, unsigned Offset,
|
||||
const MDNode *Variable, const MDNode *Expr) {
|
||||
assert(isa<DILocalVariable>(Variable) && "not a variable");
|
||||
assert(cast<DIExpression>(Expr)->isValid() && "not an expression");
|
||||
assert(cast<DILocalVariable>(Variable)->isValidLocationForIntrinsic(DL) &&
|
||||
"Expected inlined-at fields to agree");
|
||||
if (IsIndirect)
|
||||
return BuildMI(MF, DL, MCID)
|
||||
.addReg(Reg, RegState::Debug)
|
||||
.addImm(Offset)
|
||||
.addMetadata(Variable)
|
||||
.addMetadata(Expr);
|
||||
else {
|
||||
assert(Offset == 0 && "A direct address cannot have an offset.");
|
||||
return BuildMI(MF, DL, MCID)
|
||||
.addReg(Reg, RegState::Debug)
|
||||
.addReg(0U, RegState::Debug)
|
||||
.addMetadata(Variable)
|
||||
.addMetadata(Expr);
|
||||
}
|
||||
}
|
||||
MachineInstrBuilder BuildMI(MachineFunction &MF, DebugLoc DL,
|
||||
const MCInstrDesc &MCID, bool IsIndirect,
|
||||
unsigned Reg, unsigned Offset,
|
||||
const MDNode *Variable, const MDNode *Expr);
|
||||
|
||||
/// This version of the builder builds a DBG_VALUE intrinsic
|
||||
/// for either a value in a register or a register-indirect+offset
|
||||
/// address and inserts it at position I.
|
||||
inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB,
|
||||
MachineBasicBlock::iterator I, DebugLoc DL,
|
||||
const MCInstrDesc &MCID, bool IsIndirect,
|
||||
unsigned Reg, unsigned Offset,
|
||||
const MDNode *Variable, const MDNode *Expr) {
|
||||
assert(isa<DILocalVariable>(Variable) && "not a variable");
|
||||
assert(cast<DIExpression>(Expr)->isValid() && "not an expression");
|
||||
MachineFunction &MF = *BB.getParent();
|
||||
MachineInstr *MI =
|
||||
BuildMI(MF, DL, MCID, IsIndirect, Reg, Offset, Variable, Expr);
|
||||
BB.insert(I, MI);
|
||||
return MachineInstrBuilder(MF, MI);
|
||||
}
|
||||
|
||||
MachineInstrBuilder BuildMI(MachineBasicBlock &BB,
|
||||
MachineBasicBlock::iterator I, DebugLoc DL,
|
||||
const MCInstrDesc &MCID, bool IsIndirect,
|
||||
unsigned Reg, unsigned Offset,
|
||||
const MDNode *Variable, const MDNode *Expr);
|
||||
|
||||
inline unsigned getDefRegState(bool B) {
|
||||
return B ? RegState::Define : 0;
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "llvm/CodeGen/MachineFunction.h"
|
||||
#include "llvm/CodeGen/MachineInstr.h"
|
||||
#include "llvm/CodeGen/MachineModuleInfo.h"
|
||||
#include "llvm/IR/DebugInfo.h"
|
||||
#include "llvm/Target/TargetSubtargetInfo.h"
|
||||
|
||||
using namespace llvm;
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "llvm/CodeGen/MachineLoopInfo.h"
|
||||
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
||||
#include "llvm/CodeGen/VirtRegMap.h"
|
||||
#include "llvm/IR/DebugInfo.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "llvm/CodeGen/MachineFunctionPass.h"
|
||||
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
||||
#include "llvm/CodeGen/Passes.h"
|
||||
#include "llvm/IR/DebugInfo.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "llvm/CodeGen/MachineModuleInfo.h"
|
||||
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
||||
#include "llvm/IR/BasicBlock.h"
|
||||
#include "llvm/IR/DebugInfo.h"
|
||||
#include "llvm/IR/DiagnosticInfo.h"
|
||||
#include "llvm/IR/Instructions.h"
|
||||
#include "llvm/IR/LLVMContext.h"
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
||||
#include "llvm/IR/BasicBlock.h"
|
||||
#include "llvm/IR/Constants.h"
|
||||
#include "llvm/IR/DebugInfo.h"
|
||||
#include "llvm/IR/IRPrintingPasses.h"
|
||||
#include "llvm/IR/Instructions.h"
|
||||
#include "llvm/IR/Module.h"
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "llvm/Analysis/AliasAnalysis.h"
|
||||
#include "llvm/CodeGen/MachineConstantPool.h"
|
||||
#include "llvm/CodeGen/MachineFunction.h"
|
||||
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
||||
#include "llvm/CodeGen/MachineMemOperand.h"
|
||||
#include "llvm/CodeGen/MachineModuleInfo.h"
|
||||
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
||||
@ -1164,6 +1165,16 @@ int MachineInstr::findInlineAsmFlagIdx(unsigned OpIdx,
|
||||
return -1;
|
||||
}
|
||||
|
||||
const DILocalVariable *MachineInstr::getDebugVariable() const {
|
||||
assert(isDebugValue() && "not a DBG_VALUE");
|
||||
return cast<DILocalVariable>(getOperand(2).getMetadata());
|
||||
}
|
||||
|
||||
const DIExpression *MachineInstr::getDebugExpression() const {
|
||||
assert(isDebugValue() && "not a DBG_VALUE");
|
||||
return cast<DIExpression>(getOperand(3).getMetadata());
|
||||
}
|
||||
|
||||
const TargetRegisterClass*
|
||||
MachineInstr::getRegClassConstraint(unsigned OpIdx,
|
||||
const TargetInstrInfo *TII,
|
||||
@ -2138,3 +2149,41 @@ void MachineInstr::emitError(StringRef Msg) const {
|
||||
return MF->getMMI().getModule()->getContext().emitError(LocCookie, Msg);
|
||||
report_fatal_error(Msg);
|
||||
}
|
||||
|
||||
MachineInstrBuilder llvm::BuildMI(MachineFunction &MF, DebugLoc DL,
|
||||
const MCInstrDesc &MCID, bool IsIndirect,
|
||||
unsigned Reg, unsigned Offset,
|
||||
const MDNode *Variable, const MDNode *Expr) {
|
||||
assert(isa<DILocalVariable>(Variable) && "not a variable");
|
||||
assert(cast<DIExpression>(Expr)->isValid() && "not an expression");
|
||||
assert(cast<DILocalVariable>(Variable)->isValidLocationForIntrinsic(DL) &&
|
||||
"Expected inlined-at fields to agree");
|
||||
if (IsIndirect)
|
||||
return BuildMI(MF, DL, MCID)
|
||||
.addReg(Reg, RegState::Debug)
|
||||
.addImm(Offset)
|
||||
.addMetadata(Variable)
|
||||
.addMetadata(Expr);
|
||||
else {
|
||||
assert(Offset == 0 && "A direct address cannot have an offset.");
|
||||
return BuildMI(MF, DL, MCID)
|
||||
.addReg(Reg, RegState::Debug)
|
||||
.addReg(0U, RegState::Debug)
|
||||
.addMetadata(Variable)
|
||||
.addMetadata(Expr);
|
||||
}
|
||||
}
|
||||
|
||||
MachineInstrBuilder llvm::BuildMI(MachineBasicBlock &BB,
|
||||
MachineBasicBlock::iterator I, DebugLoc DL,
|
||||
const MCInstrDesc &MCID, bool IsIndirect,
|
||||
unsigned Reg, unsigned Offset,
|
||||
const MDNode *Variable, const MDNode *Expr) {
|
||||
assert(isa<DILocalVariable>(Variable) && "not a variable");
|
||||
assert(cast<DIExpression>(Expr)->isValid() && "not an expression");
|
||||
MachineFunction &MF = *BB.getParent();
|
||||
MachineInstr *MI =
|
||||
BuildMI(MF, DL, MCID, IsIndirect, Reg, Offset, Variable, Expr);
|
||||
BB.insert(I, MI);
|
||||
return MachineInstrBuilder(MF, MI);
|
||||
}
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "llvm/CodeGen/RegAllocRegistry.h"
|
||||
#include "llvm/CodeGen/RegisterClassInfo.h"
|
||||
#include "llvm/IR/BasicBlock.h"
|
||||
#include "llvm/IR/DebugInfo.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
||||
#include "llvm/CodeGen/StackMaps.h"
|
||||
#include "llvm/IR/DataLayout.h"
|
||||
#include "llvm/IR/DebugInfo.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/MathExtras.h"
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
||||
#include "llvm/IR/CallSite.h"
|
||||
#include "llvm/IR/CallingConv.h"
|
||||
#include "llvm/IR/DebugInfo.h"
|
||||
#include "llvm/IR/DerivedTypes.h"
|
||||
#include "llvm/IR/GetElementPtrTypeIterator.h"
|
||||
#include "llvm/IR/GlobalAlias.h"
|
||||
|
Loading…
Reference in New Issue
Block a user