aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Bearman <ianb@microsoft.com>2022-03-15 13:31:25 -0700
committerStella Stamenova <stilis@microsoft.com>2022-03-15 14:48:50 -0700
commit7ecb7efc898981c980a1ce50f0ef32b337e66bb9 (patch)
treeb1b492415ffaa19e31b19d69b70e07d8749d0a5a
parent6be457c14dafd634989c2c0b702a9231b438e2c4 (diff)
downloadllvm-7ecb7efc898981c980a1ce50f0ef32b337e66bb9.zip
llvm-7ecb7efc898981c980a1ce50f0ef32b337e66bb9.tar.gz
llvm-7ecb7efc898981c980a1ce50f0ef32b337e66bb9.tar.bz2
[MLIR] UnknownLoc on Inlinable Calls in LLVMIR Translation
During MLIR translation to LLVMIR if an inlineable call has an UnkownLoc we get this error message: ``` inlinable function call in a function with debug info must have a !dbg location call void @callee() ``` There is code that checks for this case and strips debug information to avoid this situation. I'm expanding this code to handle the case where an debug location points at a UnknownLoc. For example, a NamedLoc whose child location is an UnknownLoc. Reviewed By: ftynse Differential Revision: https://reviews.llvm.org/D121633
-rw-r--r--mlir/lib/Target/LLVMIR/DebugTranslation.cpp8
-rw-r--r--mlir/test/Target/LLVMIR/llvmir-debug.mlir11
2 files changed, 16 insertions, 3 deletions
diff --git a/mlir/lib/Target/LLVMIR/DebugTranslation.cpp b/mlir/lib/Target/LLVMIR/DebugTranslation.cpp
index da31fdd..925a7db 100644
--- a/mlir/lib/Target/LLVMIR/DebugTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/DebugTranslation.cpp
@@ -86,9 +86,11 @@ void DebugTranslation::translate(LLVMFuncOp func, llvm::Function &llvmFunc) {
// inlinable calls in it are with debug info, otherwise the LLVM verifier will
// complain. For now, be more restricted and treat all calls as inlinable.
const bool hasCallWithoutDebugInfo =
- func.walk([](LLVM::CallOp call) {
- return call.getLoc().isa<UnknownLoc>() ? WalkResult::interrupt()
- : WalkResult::advance();
+ func.walk([&](LLVM::CallOp call) {
+ return call.getLoc()->walk([](Location l) {
+ return l.isa<UnknownLoc>() ? WalkResult::interrupt()
+ : WalkResult::advance();
+ });
})
.wasInterrupted();
if (hasCallWithoutDebugInfo)
diff --git a/mlir/test/Target/LLVMIR/llvmir-debug.mlir b/mlir/test/Target/LLVMIR/llvmir-debug.mlir
index 590fb8b..b839a82 100644
--- a/mlir/test/Target/LLVMIR/llvmir-debug.mlir
+++ b/mlir/test/Target/LLVMIR/llvmir-debug.mlir
@@ -1,5 +1,16 @@
// RUN: mlir-translate -mlir-to-llvmir %s | FileCheck %s
+// CHECK-LABEL: define void @func_with_empty_named_info()
+// Check that translation doens't crash in the presence of an inlineble call
+// with a named loc that has no backing source info.
+llvm.func @callee() {
+ llvm.return
+} loc("calleesource.cc":1:1)
+llvm.func @func_with_empty_named_info() {
+ llvm.call @callee() : () -> () loc("named with no line info")
+ llvm.return
+}
+
// CHECK-LABEL: define void @func_no_debug()
// CHECK-NOT: !dbg
llvm.func @func_no_debug() {