[Mlir-commits] [mlir] [MLIR][LLVM] Add DILocAttr for debug locations (PR #186146)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Mar 12 08:26:05 PDT 2026
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp -- mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp mlir/lib/Dialect/LLVMIR/Transforms/DIScopeForLLVMFuncOp.cpp mlir/lib/Dialect/LLVMIR/Transforms/InlinerInterfaceImpl.cpp mlir/lib/Target/LLVMIR/DebugImporter.cpp mlir/lib/Target/LLVMIR/DebugTranslation.cpp mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp mlir/lib/Target/LLVMIR/LoopAnnotationImporter.cpp --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/mlir/lib/Dialect/LLVMIR/Transforms/DIScopeForLLVMFuncOp.cpp b/mlir/lib/Dialect/LLVMIR/Transforms/DIScopeForLLVMFuncOp.cpp
index cb4cb7cab..9e737b336 100644
--- a/mlir/lib/Dialect/LLVMIR/Transforms/DIScopeForLLVMFuncOp.cpp
+++ b/mlir/lib/Dialect/LLVMIR/Transforms/DIScopeForLLVMFuncOp.cpp
@@ -139,9 +139,9 @@ static void setLexicalBlockFileAttr(Operation *op) {
return;
if (auto callSiteLoc = dyn_cast<CallSiteLoc>(opLoc)) {
- op->setLoc(CallSiteLoc::get(
- getNestedLoc(op, scopeAttr, callSiteLoc.getCallee()),
- callSiteLoc.getCaller()));
+ op->setLoc(
+ CallSiteLoc::get(getNestedLoc(op, scopeAttr, callSiteLoc.getCallee()),
+ callSiteLoc.getCaller()));
return;
}
diff --git a/mlir/lib/Target/LLVMIR/DebugImporter.cpp b/mlir/lib/Target/LLVMIR/DebugImporter.cpp
index 2fe5f8a0a..dd89bcbb8 100644
--- a/mlir/lib/Target/LLVMIR/DebugImporter.cpp
+++ b/mlir/lib/Target/LLVMIR/DebugImporter.cpp
@@ -36,8 +36,7 @@ Location DebugImporter::translateFuncLocation(llvm::Function *func) {
StringAttr fileName = StringAttr::get(context, subprogram->getFilename());
auto fileLoc =
FileLineColLoc::get(fileName, subprogram->getLine(), /*column=*/0);
- auto scope =
- dyn_cast_or_null<DILocalScopeAttr>(translate(subprogram));
+ auto scope = dyn_cast_or_null<DILocalScopeAttr>(translate(subprogram));
// DILocAttr requires a non-null DILocalScopeAttr, but
// translateImpl(DISubprogram*) can return null when the subprogram's parent
// scope or subroutine type cannot be translated. Preserve the file location
@@ -475,14 +474,12 @@ Location DebugImporter::translateLoc(llvm::DILocation *loc) {
return UnknownLoc::get(context);
auto fileLoc = FileLineColLoc::get(context, loc->getFilename(),
- loc->getLine(), loc->getColumn());
- auto scope =
- dyn_cast_or_null<DILocalScopeAttr>(translate(loc->getScope()));
+ loc->getLine(), loc->getColumn());
+ auto scope = dyn_cast_or_null<DILocalScopeAttr>(translate(loc->getScope()));
// DILocAttr requires a non-null DILocalScopeAttr. When the scope cannot
// be translated, preserve the file location for diagnostics.
- Location result = scope
- ? Location(DILocAttr::get(fileLoc, scope))
- : Location(fileLoc);
+ Location result =
+ scope ? Location(DILocAttr::get(fileLoc, scope)) : Location(fileLoc);
if (llvm::DILocation *inlinedAt = loc->getInlinedAt())
result = CallSiteLoc::get(result, translateLoc(inlinedAt));
return result;
diff --git a/mlir/lib/Target/LLVMIR/DebugTranslation.cpp b/mlir/lib/Target/LLVMIR/DebugTranslation.cpp
index 52e322f2b..bcbaaade2 100644
--- a/mlir/lib/Target/LLVMIR/DebugTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/DebugTranslation.cpp
@@ -556,9 +556,9 @@ llvm::DILocation *DebugTranslation::translateLoc(Location loc,
return nullptr;
auto sourceLoc = diLoc.getSourceLoc();
- llvmLoc = llvm::DILocation::get(
- llvmCtx, sourceLoc.getLine(), sourceLoc.getColumn(), diScope,
- const_cast<llvm::DILocation *>(inlinedAt));
+ llvmLoc = llvm::DILocation::get(llvmCtx, sourceLoc.getLine(),
+ sourceLoc.getColumn(), diScope,
+ const_cast<llvm::DILocation *>(inlinedAt));
} else if (auto fileLoc = dyn_cast<FileLineColLoc>(loc)) {
// A scope of a DILocation cannot be null.
``````````
</details>
https://github.com/llvm/llvm-project/pull/186146
More information about the Mlir-commits
mailing list