[Mlir-commits] [mlir] 7c5362c - [mlir][LLVMDebugTranslation] Move the check for FusedLoc scope
River Riddle
llvmlistbot at llvm.org
Tue Nov 8 13:01:35 PST 2022
Author: River Riddle
Date: 2022-11-08T13:00:05-08:00
New Revision: 7c5362c7ffd2c61c06d6831706a16a0743ec8d01
URL: https://github.com/llvm/llvm-project/commit/7c5362c7ffd2c61c06d6831706a16a0743ec8d01
DIFF: https://github.com/llvm/llvm-project/commit/7c5362c7ffd2c61c06d6831706a16a0743ec8d01.diff
LOG: [mlir][LLVMDebugTranslation] Move the check for FusedLoc scope
Shift it to where we already check for FusedLoc, which removes the
need to cast multiple times.
Added:
Modified:
mlir/lib/Target/LLVMIR/DebugTranslation.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Target/LLVMIR/DebugTranslation.cpp b/mlir/lib/Target/LLVMIR/DebugTranslation.cpp
index fc3f9faaf2bf..33df6297cb4e 100644
--- a/mlir/lib/Target/LLVMIR/DebugTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/DebugTranslation.cpp
@@ -231,10 +231,6 @@ const llvm::DILocation *
DebugTranslation::translateLoc(Location loc, llvm::DILocalScope *scope) {
if (!debugEmissionIsEnabled)
return nullptr;
-
- // Check for a scope encoded with the location.
- if (auto scopedLoc = loc->findInstanceOf<FusedLocWith<LLVM::DIScopeAttr>>())
- scope = cast<llvm::DILocalScope>(translate(scopedLoc.getMetadata()));
return translateLoc(loc, scope, /*inlinedAt=*/nullptr);
}
@@ -268,6 +264,11 @@ DebugTranslation::translateLoc(Location loc, llvm::DILocalScope *scope,
} else if (auto fusedLoc = loc.dyn_cast<FusedLoc>()) {
ArrayRef<Location> locations = fusedLoc.getLocations();
+ // Check for a scope encoded with the location.
+ if (auto scopedAttr =
+ fusedLoc.getMetadata().dyn_cast_or_null<LLVM::DIScopeAttr>())
+ scope = cast<llvm::DILocalScope>(translate(scopedAttr));
+
// For fused locations, merge each of the nodes.
llvmLoc = translateLoc(locations.front(), scope, inlinedAt);
for (Location locIt : locations.drop_front()) {
More information about the Mlir-commits
mailing list