Skip to content

Commit

Permalink
[mlir][LLVMDebugTranslation] Move the check for FusedLoc scope
Browse files Browse the repository at this point in the history
Shift it to where we already check for FusedLoc, which removes the
need to cast multiple times.
  • Loading branch information
River707 committed Nov 8, 2022
1 parent 7c84984 commit 7c5362c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions mlir/lib/Target/LLVMIR/DebugTranslation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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()) {
Expand Down

0 comments on commit 7c5362c

Please sign in to comment.