File: openmp-task-target-device.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 (27 lines) | stat: -rw-r--r-- 1,168 bytes parent folder | download | duplicates (4)
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
// RUN: mlir-translate -mlir-to-llvmir %s | FileCheck %s

// This tests the fix for https://github.com/llvm/llvm-project/issues/84606
// We are only interested in ensuring that the -mlir-to-llmvir pass doesn't crash.
// CHECK: {{.*}} = add i32 {{.*}}, 5
module attributes {omp.is_target_device = true } {
  llvm.func @_QQmain() attributes {fir.bindc_name = "main", omp.declare_target = #omp.declaretarget<device_type = (host), capture_clause = (to)>} {
    %0 = llvm.mlir.constant(0 : i32) : i32
    %1 = llvm.mlir.constant(1 : i64) : i64
    %2 = llvm.alloca %1 x i32 {bindc_name = "a"} : (i64) -> !llvm.ptr<5>
    %3 = llvm.addrspacecast %2 : !llvm.ptr<5> to !llvm.ptr
    omp.task {
      llvm.store %0, %3 : i32, !llvm.ptr
      omp.terminator
    }
    %4 = omp.map.info var_ptr(%3 : !llvm.ptr, i32) map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = "a"}
    omp.target map_entries(%4 -> %arg0 : !llvm.ptr) {
    ^bb0(%arg0: !llvm.ptr):
      %5 = llvm.mlir.constant(5 : i32) : i32
      %6 = llvm.load %arg0  : !llvm.ptr -> i32
      %7 = llvm.add %6, %5  : i32
      llvm.store %7, %arg0  : i32, !llvm.ptr
      omp.terminator
    }
    llvm.return
  }
}