|
| 1 | +// RUN: mlir-translate -mlir-to-llvmir %s | FileCheck %s |
| 2 | + |
| 3 | +// Test that we don't crash when there is a call operation in the combiner |
| 4 | + |
| 5 | +omp.reduction.declare @add_f32 : f32 |
| 6 | +init { |
| 7 | +^bb0(%arg: f32): |
| 8 | + %0 = llvm.mlir.constant(0.0 : f32) : f32 |
| 9 | + omp.yield (%0 : f32) |
| 10 | +} |
| 11 | +combiner { |
| 12 | +^bb1(%arg0: f32, %arg1: f32): |
| 13 | +// test this call here: |
| 14 | + llvm.call @test_call() : () -> () |
| 15 | + %1 = llvm.fadd %arg0, %arg1 : f32 |
| 16 | + omp.yield (%1 : f32) |
| 17 | +} |
| 18 | +atomic { |
| 19 | +^bb2(%arg2: !llvm.ptr, %arg3: !llvm.ptr): |
| 20 | + %2 = llvm.load %arg3 : !llvm.ptr -> f32 |
| 21 | + llvm.atomicrmw fadd %arg2, %2 monotonic : !llvm.ptr, f32 |
| 22 | + omp.yield |
| 23 | +} |
| 24 | + |
| 25 | +llvm.func @simple_reduction(%lb : i64, %ub : i64, %step : i64) { |
| 26 | + %c1 = llvm.mlir.constant(1 : i32) : i32 |
| 27 | + %0 = llvm.alloca %c1 x i32 : (i32) -> !llvm.ptr |
| 28 | + omp.parallel { |
| 29 | + omp.wsloop reduction(@add_f32 %0 -> %prv : !llvm.ptr) |
| 30 | + for (%iv) : i64 = (%lb) to (%ub) step (%step) { |
| 31 | + %1 = llvm.mlir.constant(2.0 : f32) : f32 |
| 32 | + %2 = llvm.load %prv : !llvm.ptr -> f32 |
| 33 | + %3 = llvm.fadd %1, %2 : f32 |
| 34 | + llvm.store %3, %prv : f32, !llvm.ptr |
| 35 | + omp.yield |
| 36 | + } |
| 37 | + omp.terminator |
| 38 | + } |
| 39 | + llvm.return |
| 40 | +} |
| 41 | + |
| 42 | +llvm.func @test_call() -> () |
| 43 | + |
| 44 | +// Call to the troublesome function will have been inlined twice: once into |
| 45 | +// main and once into the outlined function |
| 46 | +// CHECK: call void @test_call() |
| 47 | +// CHECK: call void @test_call() |
0 commit comments