mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-10-25 10:27:04 +00:00
DebugInfo: Remove 'inlinedAt:' field from MDLocalVariable
Remove 'inlinedAt:' from MDLocalVariable. Besides saving some memory (variables with it seem to be single largest `Metadata` contributer to memory usage right now in -g -flto builds), this stops optimization and backend passes from having to change local variables. The 'inlinedAt:' field was used by the backend in two ways: 1. To tell the backend whether and into what a variable was inlined. 2. To create a unique id for each inlined variable. Instead, rely on the 'inlinedAt:' field of the intrinsic's `!dbg` attachment, and change the DWARF backend to use a typedef called `InlinedVariable` which is `std::pair<MDLocalVariable*, MDLocation*>`. This `DebugLoc` is already passed reliably through the backend (as verified by r234021). This commit removes the check from r234021, but I added a new check (that will survive) in r235048, and changed the `DIBuilder` API in r235041 to require a `!dbg` attachment whose 'scope:` is in the same `MDSubprogram` as the variable's. If this breaks your out-of-tree testcases, perhaps the script I used (mdlocalvariable-drop-inlinedat.sh) will help; I'll attach it to PR22778 in a moment. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235050 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -33,7 +33,7 @@ static unsigned isDescribedByReg(const MachineInstr &MI) {
|
||||
return MI.getOperand(0).isReg() ? MI.getOperand(0).getReg() : 0;
|
||||
}
|
||||
|
||||
void DbgValueHistoryMap::startInstrRange(const MDNode *Var,
|
||||
void DbgValueHistoryMap::startInstrRange(InlinedVariable Var,
|
||||
const MachineInstr &MI) {
|
||||
// Instruction range should start with a DBG_VALUE instruction for the
|
||||
// variable.
|
||||
@@ -48,7 +48,7 @@ void DbgValueHistoryMap::startInstrRange(const MDNode *Var,
|
||||
Ranges.push_back(std::make_pair(&MI, nullptr));
|
||||
}
|
||||
|
||||
void DbgValueHistoryMap::endInstrRange(const MDNode *Var,
|
||||
void DbgValueHistoryMap::endInstrRange(InlinedVariable Var,
|
||||
const MachineInstr &MI) {
|
||||
auto &Ranges = VarInstrRanges[Var];
|
||||
// Verify that the current instruction range is not yet closed.
|
||||
@@ -59,7 +59,7 @@ void DbgValueHistoryMap::endInstrRange(const MDNode *Var,
|
||||
Ranges.back().second = &MI;
|
||||
}
|
||||
|
||||
unsigned DbgValueHistoryMap::getRegisterForVar(const MDNode *Var) const {
|
||||
unsigned DbgValueHistoryMap::getRegisterForVar(InlinedVariable Var) const {
|
||||
const auto &I = VarInstrRanges.find(Var);
|
||||
if (I == VarInstrRanges.end())
|
||||
return 0;
|
||||
@@ -71,12 +71,13 @@ unsigned DbgValueHistoryMap::getRegisterForVar(const MDNode *Var) const {
|
||||
|
||||
namespace {
|
||||
// Maps physreg numbers to the variables they describe.
|
||||
typedef std::map<unsigned, SmallVector<const MDNode *, 1>> RegDescribedVarsMap;
|
||||
typedef DbgValueHistoryMap::InlinedVariable InlinedVariable;
|
||||
typedef std::map<unsigned, SmallVector<InlinedVariable, 1>> RegDescribedVarsMap;
|
||||
}
|
||||
|
||||
// \brief Claim that @Var is not described by @RegNo anymore.
|
||||
static void dropRegDescribedVar(RegDescribedVarsMap &RegVars,
|
||||
unsigned RegNo, const MDNode *Var) {
|
||||
static void dropRegDescribedVar(RegDescribedVarsMap &RegVars, unsigned RegNo,
|
||||
InlinedVariable Var) {
|
||||
const auto &I = RegVars.find(RegNo);
|
||||
assert(RegNo != 0U && I != RegVars.end());
|
||||
auto &VarSet = I->second;
|
||||
@@ -89,8 +90,8 @@ static void dropRegDescribedVar(RegDescribedVarsMap &RegVars,
|
||||
}
|
||||
|
||||
// \brief Claim that @Var is now described by @RegNo.
|
||||
static void addRegDescribedVar(RegDescribedVarsMap &RegVars,
|
||||
unsigned RegNo, const MDNode *Var) {
|
||||
static void addRegDescribedVar(RegDescribedVarsMap &RegVars, unsigned RegNo,
|
||||
InlinedVariable Var) {
|
||||
assert(RegNo != 0U);
|
||||
auto &VarSet = RegVars[RegNo];
|
||||
assert(std::find(VarSet.begin(), VarSet.end(), Var) == VarSet.end());
|
||||
@@ -203,9 +204,13 @@ void llvm::calculateDbgValueHistory(const MachineFunction *MF,
|
||||
// Use the base variable (without any DW_OP_piece expressions)
|
||||
// as index into History. The full variables including the
|
||||
// piece expressions are attached to the MI.
|
||||
DIVariable Var = MI.getDebugVariable();
|
||||
assert(Var->isValidLocationForIntrinsic(MI.getDebugLoc()) &&
|
||||
MDLocalVariable *RawVar = MI.getDebugVariable();
|
||||
assert(RawVar->isValidLocationForIntrinsic(MI.getDebugLoc()) &&
|
||||
"Expected inlined-at fields to agree");
|
||||
MDLocation *IA = nullptr;
|
||||
if (MDLocation *Loc = MI.getDebugLoc())
|
||||
IA = Loc->getInlinedAt();
|
||||
InlinedVariable Var(RawVar, IA);
|
||||
|
||||
if (unsigned PrevReg = Result.getRegisterForVar(Var))
|
||||
dropRegDescribedVar(RegVars, PrevReg, Var);
|
||||
|
||||
Reference in New Issue
Block a user