[Mlir-commits] [mlir] 7c84984 - [mlir][LLVMDebugTranslation] Add inlinedAt to the key when caching locations

River Riddle llvmlistbot at llvm.org
Tue Nov 8 13:01:33 PST 2022


Author: River Riddle
Date: 2022-11-08T13:00:05-08:00
New Revision: 7c849845e09a90fa9948afb207e755bbecb80484

URL: https://github.com/llvm/llvm-project/commit/7c849845e09a90fa9948afb207e755bbecb80484
DIFF: https://github.com/llvm/llvm-project/commit/7c849845e09a90fa9948afb207e755bbecb80484.diff

LOG: [mlir][LLVMDebugTranslation] Add inlinedAt to the key when caching locations

This avoids accidentally using the wrong inlined at scope when translating
locations.

Added: 
    

Modified: 
    mlir/lib/Target/LLVMIR/DebugTranslation.cpp
    mlir/lib/Target/LLVMIR/DebugTranslation.h
    mlir/test/Target/LLVMIR/llvmir-debug.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Target/LLVMIR/DebugTranslation.cpp b/mlir/lib/Target/LLVMIR/DebugTranslation.cpp
index 3dbb3f719e5b3..fc3f9faaf2bfc 100644
--- a/mlir/lib/Target/LLVMIR/DebugTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/DebugTranslation.cpp
@@ -247,7 +247,7 @@ DebugTranslation::translateLoc(Location loc, llvm::DILocalScope *scope,
     return nullptr;
 
   // Check for a cached instance.
-  auto existingIt = locationToLoc.find(std::make_pair(loc, scope));
+  auto existingIt = locationToLoc.find(std::make_tuple(loc, scope, inlinedAt));
   if (existingIt != locationToLoc.end())
     return existingIt->second;
 
@@ -285,7 +285,7 @@ DebugTranslation::translateLoc(Location loc, llvm::DILocalScope *scope,
     llvm_unreachable("unknown location kind");
   }
 
-  locationToLoc.try_emplace(std::make_pair(loc, scope), llvmLoc);
+  locationToLoc.try_emplace(std::make_tuple(loc, scope, inlinedAt), llvmLoc);
   return llvmLoc;
 }
 

diff  --git a/mlir/lib/Target/LLVMIR/DebugTranslation.h b/mlir/lib/Target/LLVMIR/DebugTranslation.h
index 14bd3b5162fa7..79f132696c24f 100644
--- a/mlir/lib/Target/LLVMIR/DebugTranslation.h
+++ b/mlir/lib/Target/LLVMIR/DebugTranslation.h
@@ -77,7 +77,8 @@ class DebugTranslation {
 
   /// A mapping between mlir location+scope and the corresponding llvm debug
   /// metadata.
-  DenseMap<std::pair<Location, llvm::DILocalScope *>, const llvm::DILocation *>
+  DenseMap<std::tuple<Location, llvm::DILocalScope *, const llvm::DILocation *>,
+           const llvm::DILocation *>
       locationToLoc;
 
   /// A mapping between debug attribute and the corresponding llvm debug

diff  --git a/mlir/test/Target/LLVMIR/llvmir-debug.mlir b/mlir/test/Target/LLVMIR/llvmir-debug.mlir
index 72f8f746b9769..be5142a781046 100644
--- a/mlir/test/Target/LLVMIR/llvmir-debug.mlir
+++ b/mlir/test/Target/LLVMIR/llvmir-debug.mlir
@@ -64,7 +64,7 @@ llvm.func @func_with_debug(%arg: i64) {
   llvm.call @func_no_debug() : () -> () loc("named"("foo.mlir":10:10))
 
   // CHECK: call void @func_no_debug(), !dbg ![[FUSED_LOC:[0-9]+]]
-  llvm.call @func_no_debug() : () -> () loc(fused[callsite("mysource.cc":1:1 at "mysource.cc":5:6), "mysource.cc":1:1])
+  llvm.call @func_no_debug() : () -> () loc(fused[callsite("mysource.cc":5:6 at "mysource.cc":1:1), "mysource.cc":1:1])
 
   llvm.return
 } loc(fused<#sp>["foo.mlir":1:1])


        


More information about the Mlir-commits mailing list