diff --git a/mlir/lib/Target/LLVMIR/DebugTranslation.cpp b/mlir/lib/Target/LLVMIR/DebugTranslation.cpp --- a/mlir/lib/Target/LLVMIR/DebugTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/DebugTranslation.cpp @@ -86,9 +86,11 @@ // 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() ? WalkResult::interrupt() - : WalkResult::advance(); + func.walk([&](LLVM::CallOp call) { + return call.getLoc()->walk([](Location l) { + return l.isa() ? 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 --- 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() {