llvm.org GIT mirror llvm / 40485c2
Move VariableDbgInfo from MachineModuleInfo to MachineFunction VariableDbgInfo is per function data, so it makes sense to have it with the function instead of the module. This is a necessary step to have machine module passes work properly. Differential Revision: https://reviews.llvm.org/D27186 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288292 91177308-0d34-0410-b5e6-96231b3b80d8 Matthias Braun 3 years ago
11 changed file(s) with 57 addition(s) and 60 deletion(s). Raw diff Collapse all Expand all
263263 /// \pre Fn, Target, MMI, and FunctionNumber are properly set.
264264 void init();
265265 public:
266
267 struct VariableDbgInfo {
268 const DILocalVariable *Var;
269 const DIExpression *Expr;
270 unsigned Slot;
271 const DILocation *Loc;
272
273 VariableDbgInfo(const DILocalVariable *Var, const DIExpression *Expr,
274 unsigned Slot, const DILocation *Loc)
275 : Var(Var), Expr(Expr), Slot(Slot), Loc(Loc) {}
276 };
277 typedef SmallVector VariableDbgInfoMapTy;
278 VariableDbgInfoMapTy VariableDbgInfos;
279
266280 MachineFunction(const Function *Fn, const TargetMachine &TM,
267281 unsigned FunctionNum, MachineModuleInfo &MMI);
268282 ~MachineFunction();
656670 FrameInstructions.push_back(Inst);
657671 return FrameInstructions.size() - 1;
658672 }
673
674 /// Collect information used to emit debugging information of a variable.
675 void setVariableDbgInfo(const DILocalVariable *Var, const DIExpression *Expr,
676 unsigned Slot, const DILocation *Loc) {
677 VariableDbgInfos.emplace_back(Var, Expr, Slot, Loc);
678 }
679
680 VariableDbgInfoMapTy &getVariableDbgInfo() { return VariableDbgInfos; }
681 const VariableDbgInfoMapTy &getVariableDbgInfo() const {
682 return VariableDbgInfos;
683 }
659684 };
660685
661686 //===--------------------------------------------------------------------===//
189189 public:
190190 static char ID; // Pass identification, replacement for typeid
191191
192 struct VariableDbgInfo {
193 const DILocalVariable *Var;
194 const DIExpression *Expr;
195 unsigned Slot;
196 const DILocation *Loc;
197
198 VariableDbgInfo(const DILocalVariable *Var, const DIExpression *Expr,
199 unsigned Slot, const DILocation *Loc)
200 : Var(Var), Expr(Expr), Slot(Slot), Loc(Loc) {}
201 };
202 typedef SmallVector VariableDbgInfoMapTy;
203 VariableDbgInfoMapTy VariableDbgInfos;
204
205192 explicit MachineModuleInfo(const TargetMachine *TM = nullptr);
206193 ~MachineModuleInfo() override;
207194
395382 const std::vector &getFilterIds() const {
396383 return FilterIds;
397384 }
398
399 /// Collect information used to emit debugging information of a variable.
400 void setVariableDbgInfo(const DILocalVariable *Var, const DIExpression *Expr,
401 unsigned Slot, const DILocation *Loc) {
402 VariableDbgInfos.emplace_back(Var, Expr, Slot, Loc);
403 }
404
405 VariableDbgInfoMapTy &getVariableDbgInfo() { return VariableDbgInfos; }
406
407385 }; // End class MachineModuleInfo
408386
409387 //===- MMI building helpers -----------------------------------------------===//
863863 return DR;
864864 }
865865
866 void CodeViewDebug::collectVariableInfoFromMMITable(
866 void CodeViewDebug::collectVariableInfoFromMFTable(
867867 DenseSet &Processed) {
868 const TargetSubtargetInfo &TSI = Asm->MF->getSubtarget();
868 const MachineFunction &MF = *Asm->MF;
869 const TargetSubtargetInfo &TSI = MF.getSubtarget();
869870 const TargetFrameLowering *TFI = TSI.getFrameLowering();
870871 const TargetRegisterInfo *TRI = TSI.getRegisterInfo();
871872
872 for (const MachineModuleInfo::VariableDbgInfo &VI :
873 MMI->getVariableDbgInfo()) {
873 for (const MachineFunction::VariableDbgInfo &VI : MF.getVariableDbgInfo()) {
874874 if (!VI.Var)
875875 continue;
876876 assert(VI.Var->isValidLocationForIntrinsic(VI.Loc) &&
907907 void CodeViewDebug::collectVariableInfo(const DISubprogram *SP) {
908908 DenseSet Processed;
909909 // Grab the variable info that was squirreled away in the MMI side-table.
910 collectVariableInfoFromMMITable(Processed);
910 collectVariableInfoFromMFTable(Processed);
911911
912912 const TargetRegisterInfo *TRI = Asm->MF->getSubtarget().getRegisterInfo();
913913
226226
227227 void collectVariableInfo(const DISubprogram *SP);
228228
229 void collectVariableInfoFromMMITable(DenseSet &Processed);
229 void collectVariableInfoFromMFTable(DenseSet &Processed);
230230
231231 /// Records information about a local variable in the appropriate scope. In
232232 /// particular, locals from inlined code live inside the inlining site.
725725 createAbstractVariable(Cleansed, Scope);
726726 }
727727
728 // Collect variable information from side table maintained by MMI.
729 void DwarfDebug::collectVariableInfoFromMMITable(
728 // Collect variable information from side table maintained by MF.
729 void DwarfDebug::collectVariableInfoFromMFTable(
730730 DenseSet &Processed) {
731 for (const auto &VI : MMI->getVariableDbgInfo()) {
731 for (const auto &VI : Asm->MF->getVariableDbgInfo()) {
732732 if (!VI.Var)
733733 continue;
734734 assert(VI.Var->isValidLocationForIntrinsic(VI.Loc) &&
938938 const DISubprogram *SP,
939939 DenseSet &Processed) {
940940 // Grab the variable info that was squirreled away in the MMI side-table.
941 collectVariableInfoFromMMITable(Processed);
941 collectVariableInfoFromMFTable(Processed);
942942
943943 for (const auto &I : DbgValues) {
944944 InlinedVariable IV = I.first;
439439 void buildLocationList(SmallVectorImpl &DebugLoc,
440440 const DbgValueHistoryMap::InstrRanges &Ranges);
441441
442 /// Collect variable information from the side table maintained
443 /// by MMI.
444 void collectVariableInfoFromMMITable(DenseSet &P);
442 /// Collect variable information from the side table maintained by MF.
443 void collectVariableInfoFromMFTable(DenseSet &P);
445444
446445 public:
447446 //===--------------------------------------------------------------------===//
673673 typecheckMDNode(DIExpr, Expr, Object.DebugExpr, "DIExpression", *this) ||
674674 typecheckMDNode(DILoc, Loc, Object.DebugLoc, "DILocation", *this))
675675 return true;
676 PFS.MF.getMMI().setVariableDbgInfo(DIVar, DIExpr, unsigned(FrameIdx), DILoc);
676 PFS.MF.setVariableDbgInfo(DIVar, DIExpr, unsigned(FrameIdx), DILoc);
677677 return false;
678678 }
679679
8989 const MachineConstantPool &ConstantPool);
9090 void convert(ModuleSlotTracker &MST, yaml::MachineJumpTable &YamlJTI,
9191 const MachineJumpTableInfo &JTI);
92 void convertStackObjects(yaml::MachineFunction &MF,
93 const MachineFrameInfo &MFI, MachineModuleInfo &MMI,
94 ModuleSlotTracker &MST,
95 const TargetRegisterInfo *TRI);
92 void convertStackObjects(yaml::MachineFunction &YMF,
93 const MachineFunction &MF, ModuleSlotTracker &MST);
9694
9795 private:
9896 void initRegisterMaskIds(const MachineFunction &MF);
187185 ModuleSlotTracker MST(MF.getFunction()->getParent());
188186 MST.incorporateFunction(*MF.getFunction());
189187 convert(MST, YamlMF.FrameInfo, MF.getFrameInfo());
190 convertStackObjects(YamlMF, MF.getFrameInfo(), MF.getMMI(), MST,
191 MF.getSubtarget().getRegisterInfo());
188 convertStackObjects(YamlMF, MF, MST);
192189 if (const auto *ConstantPool = MF.getConstantPool())
193190 convert(YamlMF, *ConstantPool);
194191 if (const auto *JumpTableInfo = MF.getJumpTableInfo())
285282 }
286283 }
287284
288 void MIRPrinter::convertStackObjects(yaml::MachineFunction &MF,
289 const MachineFrameInfo &MFI,
290 MachineModuleInfo &MMI,
291 ModuleSlotTracker &MST,
292 const TargetRegisterInfo *TRI) {
285 void MIRPrinter::convertStackObjects(yaml::MachineFunction &YMF,
286 const MachineFunction &MF,
287 ModuleSlotTracker &MST) {
288 const MachineFrameInfo &MFI = MF.getFrameInfo();
289 const TargetRegisterInfo *TRI = MF.getSubtarget().getRegisterInfo();
293290 // Process fixed stack objects.
294291 unsigned ID = 0;
295292 for (int I = MFI.getObjectIndexBegin(); I < 0; ++I) {
306303 YamlObject.Alignment = MFI.getObjectAlignment(I);
307304 YamlObject.IsImmutable = MFI.isImmutableObjectIndex(I);
308305 YamlObject.IsAliased = MFI.isAliasedObjectIndex(I);
309 MF.FixedStackObjects.push_back(YamlObject);
306 YMF.FixedStackObjects.push_back(YamlObject);
310307 StackObjectOperandMapping.insert(
311308 std::make_pair(I, FrameIndexOperand::createFixed(ID++)));
312309 }
331328 YamlObject.Size = MFI.getObjectSize(I);
332329 YamlObject.Alignment = MFI.getObjectAlignment(I);
333330
334 MF.StackObjects.push_back(YamlObject);
331 YMF.StackObjects.push_back(YamlObject);
335332 StackObjectOperandMapping.insert(std::make_pair(
336333 I, FrameIndexOperand::create(YamlObject.Name.Value, ID++)));
337334 }
344341 "Invalid stack object index");
345342 const FrameIndexOperand &StackObject = StackObjectInfo->second;
346343 if (StackObject.IsFixed)
347 MF.FixedStackObjects[StackObject.ID].CalleeSavedRegister = Reg;
344 YMF.FixedStackObjects[StackObject.ID].CalleeSavedRegister = Reg;
348345 else
349 MF.StackObjects[StackObject.ID].CalleeSavedRegister = Reg;
346 YMF.StackObjects[StackObject.ID].CalleeSavedRegister = Reg;
350347 }
351348 for (unsigned I = 0, E = MFI.getLocalFrameObjectCount(); I < E; ++I) {
352349 auto LocalObject = MFI.getLocalFrameObjectMap(I);
355352 "Invalid stack object index");
356353 const FrameIndexOperand &StackObject = StackObjectInfo->second;
357354 assert(!StackObject.IsFixed && "Expected a locally mapped stack object");
358 MF.StackObjects[StackObject.ID].LocalOffset = LocalObject.second;
355 YMF.StackObjects[StackObject.ID].LocalOffset = LocalObject.second;
359356 }
360357
361358 // Print the stack object references in the frame information class after
362359 // converting the stack objects.
363360 if (MFI.hasStackProtectorIndex()) {
364 raw_string_ostream StrOS(MF.FrameInfo.StackProtector.Value);
361 raw_string_ostream StrOS(YMF.FrameInfo.StackProtector.Value);
365362 MIPrinter(StrOS, MST, RegisterMaskIds, StackObjectOperandMapping)
366363 .printStackObjectReference(MFI.getStackProtectorIndex());
367364 }
368365
369366 // Print the debug variable information.
370 for (MachineModuleInfo::VariableDbgInfo &DebugVar :
371 MMI.getVariableDbgInfo()) {
367 for (const MachineFunction::VariableDbgInfo &DebugVar :
368 MF.getVariableDbgInfo()) {
372369 auto StackObjectInfo = StackObjectOperandMapping.find(DebugVar.Slot);
373370 assert(StackObjectInfo != StackObjectOperandMapping.end() &&
374371 "Invalid stack object index");
375372 const FrameIndexOperand &StackObject = StackObjectInfo->second;
376373 assert(!StackObject.IsFixed && "Expected a non-fixed stack object");
377 auto &Object = MF.StackObjects[StackObject.ID];
374 auto &Object = YMF.StackObjects[StackObject.ID];
378375 {
379376 raw_string_ostream StrOS(Object.DebugVar.Value);
380377 DebugVar.Var->printAsOperand(StrOS, MST);
239239 CallsEHReturn = false;
240240 CallsUnwindInit = false;
241241 HasEHFunclets = false;
242 VariableDbgInfos.clear();
243242 }
244243
245244 //===- Address of Block Management ----------------------------------------===//
235235 StaticAllocaMap.find(AI);
236236 if (SI != StaticAllocaMap.end()) { // Check for VLAs.
237237 int FI = SI->second;
238 MMI.setVariableDbgInfo(DI->getVariable(), DI->getExpression(),
238 MF->setVariableDbgInfo(DI->getVariable(), DI->getExpression(),
239239 FI, DI->getDebugLoc());
240240 }
241241 }
777777 unsigned FixedInstr = 0;
778778 unsigned FixedMemOp = 0;
779779 unsigned FixedDbg = 0;
780 MachineModuleInfo *MMI = &MF->getMMI();
781780
782781 // Remap debug information that refers to stack slots.
783 for (auto &VI : MMI->getVariableDbgInfo()) {
782 for (auto &VI : MF->getVariableDbgInfo()) {
784783 if (!VI.Var)
785784 continue;
786785 if (SlotRemap.count(VI.Slot)) {