1 // RUN: mlir-opt -allow-unregistered-dialect %s -mlir-print-debuginfo -mlir-print-local-scope | FileCheck %s
2 // RUN: mlir-opt -allow-unregistered-dialect %s -mlir-print-debuginfo | FileCheck %s --check-prefix=CHECK-ALIAS
3 // RUN: mlir-opt -allow-unregistered-dialect %s -mlir-print-debuginfo | mlir-opt -allow-unregistered-dialect -mlir-print-debuginfo | FileCheck %s --check-prefix=CHECK-ALIAS
4 // This test verifies that debug locations are round-trippable.
6 #set0 = affine_set<(d0) : (1 == 0)>
8 // CHECK-LABEL: func @inline_notation
9 func.func @inline_notation() -> i32 {
10 // CHECK: -> i32 loc("foo")
11 %1 = "foo"() : () -> i32 loc("foo")
13 // CHECK: arith.constant 4 : index loc(callsite("foo" at "mysource.cc":10:8))
14 %2 = arith.constant 4 : index loc(callsite("foo" at "mysource.cc":10:8))
16 // CHECK: affine.for %arg0 loc("IVlocation") = 0 to 8 {
17 // CHECK: } loc(fused["foo", "mysource.cc":10:8])
18 affine.for %i0 loc("IVlocation") = 0 to 8 {
19 } loc(fused["foo", "mysource.cc":10:8])
21 // CHECK: } loc(fused<"myPass">["foo", "foo2"])
23 } loc(fused<"myPass">["foo", "foo2"])
25 // CHECK: } loc(fused<"myPass">["foo"])
27 } loc(fused<"myPass">["foo"])
29 // CHECK: return %0 : i32 loc(unknown)
30 return %1 : i32 loc(unknown)
33 // CHECK-LABEL: func private @loc_attr(i1 {foo.loc_attr = loc(callsite("foo" at "mysource.cc":10:8))})
34 func.func private @loc_attr(i1 {foo.loc_attr = loc(callsite("foo" at "mysource.cc":10:8))})
36 // Check that locations get properly escaped.
37 // CHECK-LABEL: func @escape_strings()
38 func.func @escape_strings() {
39 // CHECK: loc("escaped\0A")
40 "foo"() : () -> () loc("escaped\n")
42 // CHECK: loc("escaped\0A")
43 "foo"() : () -> () loc("escaped\0A")
45 // CHECK: loc("escaped\0A":0:0)
46 "foo"() : () -> () loc("escaped\n":0:0)
50 // CHECK-ALIAS: "foo.op"() : () -> () loc(#[[LOC:.*]])
51 "foo.op"() : () -> () loc(#loc)
53 // CHECK-LABEL: func @argLocs(
54 // CHECK-SAME: %arg0: i32 loc({{.*}}locations.mlir":[[# @LINE+1]]:20),
55 func.func @argLocs(%x: i32,
56 // CHECK-SAME: %arg1: i64 loc("hotdog")
57 %y: i64 loc("hotdog")) {
61 // CHECK-LABEL: "foo.unknown_op_with_bbargs"()
62 // CHECK-ALIAS: "foo.unknown_op_with_bbargs"()
63 "foo.unknown_op_with_bbargs"() ({
64 // CHECK-NEXT: ^bb0(%arg0: i32 loc({{.*}}locations.mlir":[[# @LINE+2]]:7),
65 // CHECK-ALIAS-NEXT: ^bb0(%arg0: i32 loc({{.*}}locations.mlir":[[# @LINE+1]]:7),
67 // CHECK-SAME: %arg1: i32 loc("cheetos"),
68 // CHECK-ALIAS-SAME: %arg1: i32 loc("cheetos"),
69 %y: i32 loc("cheetos"),
70 // CHECK-SAME: %arg2: i32 loc("out_of_line_location2")):
71 // CHECK-ALIAS-SAME: %arg2: i32 loc("out_of_line_location2")):
72 %z: i32 loc("out_of_line_location2")):
73 %1 = arith.addi %x, %y : i32
74 "foo.yield"(%1) : (i32) -> ()
77 // CHECK-LABEL: func @location_name_child_is_name
78 func.func @location_name_child_is_name() {
79 // CHECK: "foo"("foo")
80 return loc("foo"("foo"))
83 // CHECK-ALIAS: #[[LOC]] = loc("out_of_line_location")
84 #loc = loc("out_of_line_location")
86 // CHECK-LABEL: @optional_location_specifier
87 // CHECK: test.attr_with_loc("foo" loc("foo_loc"))
88 func.func @optional_location_specifier() {
89 test.attr_with_loc("foo" loc("foo_loc"))
93 // CHECK-LABEL: @dialect_location
94 // CHECK: test.attr_with_loc("dialectLoc" loc(#test.custom_location<"foo.mlir" * 32>))
95 func.func @dialect_location() {
96 test.attr_with_loc("dialectLoc" loc(#test.custom_location<"foo.mlir"*32>))