[Mlir-commits] [mlir] [MLIR][LLVM] Add DILocAttr for debug locations (PR #186146)

Aman LaChapelle llvmlistbot at llvm.org
Thu Mar 12 13:54:01 PDT 2026


================
@@ -487,16 +487,15 @@ static void handleAccessGroups(Operation *call,
 static void
 handleLoopAnnotations(Operation *call,
                       iterator_range<Region::iterator> inlinedBlocks) {
-  // Attempt to extract a DISubprogram from the callee.
+  // Attempt to extract a DISubprogram from the caller.
   auto func = call->getParentOfType<FunctionOpInterface>();
   if (!func)
     return;
-  LocationAttr funcLoc = func->getLoc();
-  auto fusedLoc = dyn_cast_if_present<FusedLoc>(funcLoc);
-  if (!fusedLoc)
-    return;
-  auto scope =
-      dyn_cast_if_present<LLVM::DISubprogramAttr>(fusedLoc.getMetadata());
+  LLVM::DISubprogramAttr scope;
+  if (auto diLoc = func->getLoc()->findInstanceOf<LLVM::DILocAttr>())
----------------
bzcheeseman wrote:

So I have one concern around the usage of findInstanceOf in this patch, which is that I would *expect* that it returns the first instance, but that's not clear it's guaranteed to be true. In the case of e.g. a callsiteloc, which do you expect here? The scope from the caller or from the callee? Or, in parallel with FusedLoc, do we expect this to *be* an LLVM::DILocAttr?

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


More information about the Mlir-commits mailing list