[llvm] [DebugInfo][RemoveDIs] Find types hidden in DbgRecords (PR #106547)
Orlando Cazalet-Hyams via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 29 05:49:50 PDT 2024
================
@@ -88,6 +88,17 @@ void TypeFinder::run(const Module &M, bool onlyNamed) {
for (const auto &MD : MDForInst)
incorporateMDNode(MD.second);
MDForInst.clear();
+
+ // Incorporate types hiding in variable-location information.
+ for (const auto &Dbg : I.getDbgRecordRange()) {
+ // Pick out records that have Values.
+ if (Dbg.getRecordKind() != DbgRecord::Kind::ValueKind)
+ continue;
+ const DbgVariableRecord &DVI = static_cast<const DbgVariableRecord &>(Dbg);
+ for (Value *V : DVI.location_ops()) {
+ incorporateValue(V);
+ }
----------------
OCHyams wrote:
```suggestion
if (const DbgVariableRecord*DVI = dyn_cast<DbgVariableRecord>(&Dbg) {
for (Value *V : DVI->location_ops())
incorporateValue(V);
if (Value *Addr = DVI->getAddress(); Addr && DVI->isDbgAssign())
incorperateValue(Addr);
}
```
Better to use the dyn/isa casting rather than checking the subclass discriminator directly (`if (Dbg.getRecordKind() != DbgRecord::Kind::ValueKind)`)?
I think we also need to add dbg_assign address component values too (there's no operand iterator that includes that sadly).
I've incorporated both those fixes in the suggestion.
https://github.com/llvm/llvm-project/pull/106547
More information about the llvm-commits
mailing list