Skip to content

Commit e5cfb7d

Browse files
committed
Move the test into MLIR.
The original f90 ->llvmir test has been removed. I have added an MLIR -> llvmir test as per review comments.
1 parent 5508975 commit e5cfb7d

File tree

2 files changed

+72
-18
lines changed

2 files changed

+72
-18
lines changed

flang/test/Lower/OpenMP/target-debug.f90

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
// RUN: mlir-translate -mlir-to-llvmir %s | FileCheck %s
2+
3+
module attributes {omp.is_target_device = true} {
4+
llvm.func @_QQmain() {
5+
%0 = llvm.mlir.constant(1 : i64) : i64
6+
%1 = llvm.alloca %0 x i32 : (i64) -> !llvm.ptr<5>
7+
%2 = llvm.addrspacecast %1 : !llvm.ptr<5> to !llvm.ptr
8+
%3 = llvm.mlir.constant(1 : i64) : i64
9+
%4 = llvm.alloca %3 x i32 : (i64) -> !llvm.ptr<5>
10+
%5 = llvm.addrspacecast %4 : !llvm.ptr<5> to !llvm.ptr
11+
%6 = llvm.mlir.constant(1 : i64) : i64
12+
%7 = llvm.alloca %6 x i32 : (i64) -> !llvm.ptr<5>
13+
%8 = llvm.addrspacecast %7 : !llvm.ptr<5> to !llvm.ptr
14+
%9 = omp.map_info var_ptr(%2 : !llvm.ptr, i32) map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = ""}
15+
%10 = omp.map_info var_ptr(%5 : !llvm.ptr, i32) map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = ""}
16+
omp.target map_entries(%9 -> %arg0, %10 -> %arg1 : !llvm.ptr, !llvm.ptr) {
17+
^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr):
18+
%12 = llvm.mlir.constant(2 : i32) : i32
19+
%13 = llvm.mlir.constant(1 : i32) : i32
20+
%14 = llvm.load %arg0 : !llvm.ptr -> i32 loc(#loc2)
21+
%15 = llvm.add %14, %13 : i32 loc(#loc2)
22+
llvm.store %15, %arg0 : i32, !llvm.ptr loc(#loc2)
23+
%16 = llvm.load %arg0 : !llvm.ptr -> i32 loc(#loc3)
24+
%17 = llvm.add %16, %12 : i32 loc(#loc3)
25+
llvm.store %17, %arg1 : i32, !llvm.ptr loc(#loc3)
26+
omp.terminator
27+
}
28+
%11 = omp.map_info var_ptr(%8 : !llvm.ptr, i32) map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = ""}
29+
omp.target map_entries(%11 -> %arg0 : !llvm.ptr) {
30+
^bb0(%arg0: !llvm.ptr):
31+
%12 = llvm.mlir.constant(1 : i32) : i32
32+
omp.parallel {
33+
%13 = llvm.load %arg0 : !llvm.ptr -> i32 loc(#loc4)
34+
%14 = llvm.add %13, %12 : i32 loc(#loc4)
35+
llvm.store %14, %arg0 : i32, !llvm.ptr loc(#loc4)
36+
omp.terminator
37+
}
38+
omp.terminator
39+
}
40+
llvm.return
41+
} loc(#loc5)
42+
} loc(#loc)
43+
#di_basic_type = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "void", encoding = DW_ATE_address>
44+
#di_file = #llvm.di_file<"target.f90" in "">
45+
#loc = loc("target.f90":0:0)
46+
#loc1 = loc("target.f90":1:1)
47+
#loc2 = loc("target.f90":9:3)
48+
#loc3 = loc("target.f90":10:3)
49+
#loc4 = loc("target.f90":14:3)
50+
#di_compile_unit = #llvm.di_compile_unit<id = distinct[0]<>, sourceLanguage = DW_LANG_Fortran95, file = #di_file, producer = "Flang", isOptimized = false, emissionKind = LineTablesOnly>
51+
#di_subroutine_type = #llvm.di_subroutine_type<callingConvention = DW_CC_normal, types = #di_basic_type, #di_basic_type>
52+
#di_subprogram = #llvm.di_subprogram<id = distinct[1]<>, compileUnit = #di_compile_unit, scope = #di_file, name = "_QQmain", linkageName = "_QQmain", file = #di_file, line = 1, scopeLine = 1, subprogramFlags = "Definition|Optimized", type = #di_subroutine_type>
53+
#loc5 = loc(fused<#di_subprogram>[#loc1])
54+
55+
// 8: !$omp target map(tofrom: a, b)
56+
// 9: a = a + 1
57+
//10: b = a + 2
58+
//11: !$omp end target
59+
60+
//13: !$omp target parallel map(tofrom: a, b)
61+
//14: c = c + 1
62+
//15: !$omp end target parallel
63+
64+
// CHECK-DAG: [[FILE:.*]] = !DIFile(filename: "target.f90", directory: "")
65+
// CHECK-DAG: [[CU:.*]] = distinct !DICompileUnit(language: DW_LANG_Fortran95, file: [[FILE]], {{.*}})
66+
67+
// CHECK: [[SP1:.*]] = distinct !DISubprogram(name: "__omp_offloading_{{.*}}", {{.*}}, unit: [[CU]])
68+
// CHECK-DAG: !DILocation(line: 9, column: 3, scope: [[SP1]])
69+
// CHECK-DAG: !DILocation(line: 10, column: 3, scope: [[SP1]])
70+
71+
// CHECK: [[SP2:.*]] = distinct !DISubprogram(name: "__omp_offloading_{{.*}}omp_par", {{.*}}, unit: [[CU]])
72+
// CHECK: !DILocation(line: 14, column: 3, scope: [[SP2]])

0 commit comments

Comments
 (0)