File: inlining-loop-annotation.mlir

package info (click to toggle)
swiftlang 6.1.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,791,604 kB
  • sloc: cpp: 9,901,740; ansic: 2,201,431; asm: 1,091,827; python: 308,252; objc: 82,166; f90: 80,126; lisp: 38,358; pascal: 25,559; sh: 20,429; ml: 5,058; perl: 4,745; makefile: 4,484; awk: 3,535; javascript: 3,018; xml: 918; fortran: 664; cs: 573; ruby: 396
file content (56 lines) | stat: -rw-r--r-- 2,436 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// RUN: mlir-opt %s -inline -split-input-file | FileCheck %s

#di_file = #llvm.di_file<"file.mlir" in "/">

// CHECK: #[[START_ORIGINAL:.*]] = loc({{.*}}:42
#loc1 = loc("test.mlir":42:4)
// CHECK: #[[END_ORIGINAL:.*]] = loc({{.*}}:52
#loc2 = loc("test.mlir":52:4)
#loc3 = loc("test.mlir":62:4)
// CHECK: #[[CALL_ORIGINAL:.*]] = loc({{.*}}:72
#loc4 = loc("test.mlir":72:4)

#di_compile_unit = #llvm.di_compile_unit<id = distinct[0]<>, sourceLanguage = DW_LANG_C, file = #di_file, isOptimized = false, emissionKind = None>
// CHECK: #[[CALLEE_DI:.*]] = #llvm.di_subprogram<{{.*}}, name = "callee"
#di_subprogram_callee = #llvm.di_subprogram<compileUnit = #di_compile_unit, scope = #di_file, name = "callee", file = #di_file, subprogramFlags = Definition>

// CHECK: #[[CALLER_DI:.*]] = #llvm.di_subprogram<{{.*}}, name = "caller"
#di_subprogram_caller = #llvm.di_subprogram<compileUnit = #di_compile_unit, scope = #di_file, name = "caller", file = #di_file, subprogramFlags = Definition>

// CHECK: #[[START_FUSED_ORIGINAL:.*]] = loc(fused<#[[CALLEE_DI]]>[#[[START_ORIGINAL]]
#start_loc_fused = loc(fused<#di_subprogram_callee>[#loc1])
// CHECK: #[[END_FUSED_ORIGINAL:.*]] = loc(fused<#[[CALLEE_DI]]>[#[[END_ORIGINAL]]
#end_loc_fused= loc(fused<#di_subprogram_callee>[#loc2])
#caller_loc= loc(fused<#di_subprogram_caller>[#loc3])
// CHECK: #[[CALL_FUSED:.*]] = loc(fused<#[[CALLER_DI]]>[#[[CALL_ORIGINAL]]
#call_loc= loc(fused<#di_subprogram_caller>[#loc4])

#loopMD = #llvm.loop_annotation<
        startLoc = #start_loc_fused,
        endLoc = #end_loc_fused>

// CHECK: #[[START_CALLSITE_LOC:.*]] = loc(callsite(#[[START_FUSED_ORIGINAL]] at #[[CALL_FUSED]]
// CHECK: #[[END_CALLSITE_LOC:.*]] = loc(callsite(#[[END_FUSED_ORIGINAL]] at #[[CALL_FUSED]]
// CHECK: #[[START_FUSED_LOC:.*]] = loc(fused<#[[CALLER_DI]]>[#[[START_CALLSITE_LOC]]
// CHECK: #[[END_FUSED_LOC:.*]] = loc(fused<#[[CALLER_DI]]>[
// CHECK: #[[LOOP_ANNOT:.*]] = #llvm.loop_annotation<
// CHECK-SAME: startLoc = #[[START_FUSED_LOC]], endLoc = #[[END_FUSED_LOC]]>

llvm.func @cond() -> i1

llvm.func @callee() {
  llvm.br ^head
^head:
  %c = llvm.call @cond() : () -> i1
  llvm.cond_br %c, ^head, ^exit {loop_annotation = #loopMD}
^exit:
  llvm.return
}

// CHECK: @loop_annotation
llvm.func @loop_annotation() {
  // CHECK: llvm.cond_br
  // CHECK-SAME: {loop_annotation = #[[LOOP_ANNOT]]
  llvm.call @callee() : () -> () loc(#call_loc)
  llvm.return
} loc(#caller_loc)