[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


================
@@ -61,12 +61,18 @@ void DebugTranslation::translate(LLVMFuncOp func, llvm::Function &llvmFunc) {
   if (!debugEmissionIsEnabled)
     return;
 
-  // Look for a sub program attached to the function.
-  auto spLoc =
-      func.getLoc()->findInstanceOf<FusedLocWith<LLVM::DISubprogramAttr>>();
-  if (!spLoc)
+  // Look for a subprogram: check DILocAttr first, fall back to FusedLoc.
+  LLVM::DISubprogramAttr sp;
+  if (auto diLoc = func.getLoc()->findInstanceOf<LLVM::DILocAttr>()) {
+    sp = dyn_cast<LLVM::DISubprogramAttr>(diLoc.getScope());
+  } else if (auto spLoc =
+                 func.getLoc()
+                     ->findInstanceOf<FusedLocWith<LLVM::DISubprogramAttr>>()) {
----------------
bzcheeseman wrote:

same as above with findInstanceOf - in this case actually since it's on a function I'd imagine the function location pretty much has to be either DILocAttr or `FusedLocWith<DISubprogramAttr>`?

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


More information about the Mlir-commits mailing list