[Mlir-commits] [mlir] bbce1fc - [mlir] Fix verifier for call debug locations

Valentin Clement llvmlistbot at llvm.org
Wed Aug 9 09:04:19 PDT 2023


Author: Valentin Clement
Date: 2023-08-09T09:03:57-07:00
New Revision: bbce1fcbaa2768328816a01e680710d06e441828

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

LOG: [mlir] Fix verifier for call debug locations

D157096 introduces a new verifier for debug location
on call operation. `isDeclaration()` is actually not defined
for `LLVMFuncOp` and default to the interface definition that always
return `false`. This leads to wrong diagnostic in some case as shown in the added test.
Use `callee.isExternal()` instead that returns the
desired information.

We have seen this error being triggered during flang codegen.

Reviewed By: Dinistro, vzakhari

Differential Revision: https://reviews.llvm.org/D157447

Added: 
    mlir/test/Dialect/LLVMIR/call-location.mlir

Modified: 
    mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
index 2cb4cace5e445b..42846de249c54d 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
@@ -1012,7 +1012,7 @@ MutableOperandRange CallOp::getArgOperandsMutable() {
 /// debug-info-bearing function has a debug location attached to it. This
 /// mirrors an LLVM IR verifier.
 static LogicalResult verifyCallOpDebugInfo(CallOp callOp, LLVMFuncOp callee) {
-  if (callee.isDeclaration())
+  if (callee.isExternal())
     return success();
   auto parentFunc = callOp->getParentOfType<FunctionOpInterface>();
   if (!parentFunc)

diff  --git a/mlir/test/Dialect/LLVMIR/call-location.mlir b/mlir/test/Dialect/LLVMIR/call-location.mlir
new file mode 100644
index 00000000000000..1b473743bcd055
--- /dev/null
+++ b/mlir/test/Dialect/LLVMIR/call-location.mlir
@@ -0,0 +1,31 @@
+// RUN: mlir-opt %s -split-input-file | FileCheck %s
+
+#di_file = #llvm.di_file<"file.cpp" in "/folder/">
+#di_compile_unit = #llvm.di_compile_unit<
+  sourceLanguage = DW_LANG_C_plus_plus_14, file = #di_file,
+  isOptimized = true, emissionKind = Full
+>
+#di_subprogram = #llvm.di_subprogram<
+  compileUnit = #di_compile_unit, scope = #di_file,
+  name = "missing_debug_loc", file = #di_file,
+  subprogramFlags = "Definition|Optimized"
+>
+#di_subprogram1 = #llvm.di_subprogram<
+  compileUnit = #di_compile_unit, scope = #di_file,
+  name = "invalid_call_debug_locs", file = #di_file,
+  subprogramFlags = "Definition|Optimized"
+>
+#loc = loc(unknown)
+#loc1 = loc("file.cpp":24:0)
+#loc2 = loc(fused<#di_subprogram>[#loc1])
+#loc3 = loc("file.cpp":42:0)
+#loc4 = loc(fused<#di_subprogram1>[#loc3])
+
+llvm.func @external_func() loc(#loc2)
+
+llvm.func @call_debug_locs() {
+  llvm.call @external_func() : () -> () loc(#loc)
+  llvm.return
+} loc(#loc4)
+
+// CHECK: llvm.call @external_func()


        


More information about the Mlir-commits mailing list