Index: mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp =================================================================== --- mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp +++ mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp @@ -251,16 +251,9 @@ Location Importer::processDebugLoc(const llvm::DebugLoc &loc, llvm::Instruction *inst) { - if (!loc && inst) { - std::string s; - llvm::raw_string_ostream os(s); - os << "llvm-imported-inst-%"; - inst->printAsOperand(os, /*PrintType=*/false); - return FileLineColLoc::get(context, os.str(), 0, 0); - } - if (!loc) { + if (!loc) return unknownLoc; - } + // FIXME: Obtain the filename from DILocationInfo. return FileLineColLoc::get(context, "imported-bitcode", loc.getLine(), loc.getCol()); Index: mlir/test/Target/LLVMIR/Import/basic.ll =================================================================== --- mlir/test/Target/LLVMIR/Import/basic.ll +++ mlir/test/Target/LLVMIR/Import/basic.ll @@ -1,4 +1,8 @@ ; RUN: mlir-translate -import-llvm %s | FileCheck %s +; RUN: mlir-translate -import-llvm -mlir-print-debuginfo %s | FileCheck %s --check-prefix=CHECK-DBG + +; CHECK-DBG: #[[UNKNOWNLOC:.+]] = loc(unknown) +; CHECK-DBG: #[[ZEROLOC:.+]] = loc("imported-bitcode":0:0) %struct.t = type {} %struct.s = type { %struct.t, i64 } @@ -129,6 +133,7 @@ ; FIXME: function attributes. ; CHECK-LABEL: llvm.func internal @f1(%arg0: i64) -> i32 attributes {dso_local} { +; CHECK-DBG: llvm.func internal @f1(%arg0: i64 loc(unknown)) -> i32 attributes {dso_local} { ; CHECK-DAG: %[[c2:[0-9]+]] = llvm.mlir.constant(2 : i32) : i32 ; CHECK-DAG: %[[c42:[0-9]+]] = llvm.mlir.constant(42 : i32) : i32 ; CHECK-DAG: %[[c1:[0-9]+]] = llvm.mlir.constant(true) : i1 @@ -137,6 +142,7 @@ entry: ; CHECK: %{{[0-9]+}} = llvm.inttoptr %arg0 : i64 to !llvm.ptr %aa = inttoptr i64 %a to i64* +; CHECK-DBG: llvm.mlir.addressof @g2 : !llvm.ptr loc(#[[UNKNOWNLOC]]) ; %[[addrof:[0-9]+]] = llvm.mlir.addressof @g2 : !llvm.ptr ; %[[addrof2:[0-9]+]] = llvm.mlir.addressof @g2 : !llvm.ptr ; %{{[0-9]+}} = llvm.inttoptr %arg0 : i64 to !llvm.ptr @@ -145,6 +151,7 @@ %bb = ptrtoint double* @g2 to i64 %cc = getelementptr double, double* @g2, i32 2 ; CHECK: %[[b:[0-9]+]] = llvm.trunc %arg0 : i64 to i32 +; CHECK-DBG: llvm.trunc %arg0 : i64 to i32 loc(#[[ZEROLOC]]) %b = trunc i64 %a to i32 ; CHECK: %[[c:[0-9]+]] = llvm.call @fe(%[[b]]) : (i32) -> f32 %c = call float @fe(i32 %b) @@ -168,6 +175,7 @@ ; CHECK: llvm.return %[[c43]] ret i32 43 } +; CHECK-DBG: } loc(#[[UNKNOWNLOC]]) ; Test that instructions that dominate can be out of sequential order. ; CHECK-LABEL: llvm.func @f2(%arg0: i64) -> i64 {