[llvm] [DebugInfo][RemoveDIs] Find types hidden in DbgRecords (PR #106547)

Orlando Cazalet-Hyams via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 30 05:10:55 PDT 2024


================
@@ -88,6 +88,18 @@ 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 (const DbgVariableRecord *DVI =
+                  dyn_cast<DbgVariableRecord>(&Dbg)) {
+            for (Value *V : DVI->location_ops())
+              incorporateValue(V);
+            if (Value *Addr = DVI->getAddress(); Addr && DVI->isDbgAssign())
+              incorporateValue(Addr);
----------------
OCHyams wrote:

Regarding the latest change to check allow for DIArgList in `getAddress`: it's not permitted for dbg_declares or dbg_assigns address components to use DIArgList. `getAddress` returns the first DebugValue operand unless it's a dbg_assign - then it returns the second. The only reason we're seeing an DIArgList pop up in `getAddress` is because its being called before checking if `DVI->isDbgAssign()`: some dbg_value with a DIArgList is having getAddress called on it. I thought this would be fine when I wrote the suggestion above but clearly it breaks assumptions.

I think it's probably better to restructure this to:
```
if (DVI->isDbgAssign())) {
  if (Value *Addr = DVI->getAddress())
    incorporateValue(Addr);
}
```
And revert the most recent getAddress change- wdyt? Sorry for the additional hassle.

https://github.com/llvm/llvm-project/pull/106547


More information about the llvm-commits mailing list