brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.1 KiB · 7a448f7 Raw
88 lines · plain
1// RUN: mlir-translate --mlir-to-llvmir %s | FileCheck %s2 3// Regression test for a compiler crash. Ensure that the insertion point is set4// correctly when triggering the charbox hack multiple times.5// Nonsense test code to minimally reproduce the issue.6 7module {8  llvm.func @free(!llvm.ptr)9  llvm.func @malloc(i64) -> !llvm.ptr10  omp.private {type = private} @_QFEc2_private_box_heap_c8xU : !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8)> init {11  ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr):12    %0 = llvm.mlir.constant(24 : i32) : i3213    %1 = llvm.mlir.constant(0 : i64) : i6414    %2 = llvm.mlir.constant(1 : i32) : i3215    %3 = llvm.alloca %2 x !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8)> {alignment = 8 : i64} : (i32) -> !llvm.ptr16    "llvm.intr.memcpy"(%3, %arg0, %0) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i32) -> ()17    %6 = llvm.ptrtoint %arg0 : !llvm.ptr to i6418    %7 = llvm.icmp "eq" %6, %1 : i6419    llvm.cond_br %7, ^bb1, ^bb220  ^bb1:  // pred: ^bb021    llvm.br ^bb322  ^bb2:  // pred: ^bb023    llvm.br ^bb324  ^bb3:  // 2 preds: ^bb1, ^bb225    omp.yield(%arg1 : !llvm.ptr)26  } dealloc {27  ^bb0(%arg0: !llvm.ptr):28    omp.yield29  }30  omp.private {type = private} @_QFEc1_private_box_ptr_c8xU : !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8)> init {31  ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr):32    %0 = llvm.mlir.constant(24 : i32) : i3233    %1 = llvm.mlir.constant(1 : i32) : i3234    %2 = llvm.alloca %1 x !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8)> {alignment = 8 : i64} : (i32) -> !llvm.ptr35    "llvm.intr.memcpy"(%2, %arg0, %0) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i32) -> ()36    omp.yield(%arg1 : !llvm.ptr)37  }38  llvm.func @_QQmain() {39    %0 = llvm.mlir.constant(1 : i64) : i6440    %1 = llvm.alloca %0 x !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8)> {bindc_name = "c2"} : (i64) -> !llvm.ptr41    %2 = llvm.alloca %0 x !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8)> {bindc_name = "c1"} : (i64) -> !llvm.ptr42    omp.task private(@_QFEc1_private_box_ptr_c8xU %2 -> %arg0, @_QFEc2_private_box_heap_c8xU %1 -> %arg1 : !llvm.ptr, !llvm.ptr) {43      omp.terminator44    }45    llvm.return46  }47}48 49// CHECK-LABEL: @_QQmain() {50// CHECK:         %[[STRUCTARG:.*]] = alloca { ptr }, align 851// CHECK:         %[[VAL_0:.*]] = alloca { ptr, i64, i32, i8, i8, i8, i8 }, i64 1, align 852// CHECK:         br label %[[VAL_2:.*]]53// CHECK:       entry:                                            ; preds = %[[VAL_3:.*]]54// CHECK:         br label %[[VAL_4:.*]]55// CHECK:       omp.private.init:                                 ; preds = %[[VAL_2]]56// CHECK:         %[[VAL_5:.*]] = tail call ptr @malloc(i64 ptrtoint (ptr getelementptr ({ { ptr, i64, i32, i8, i8, i8, i8 }, { ptr, i64, i32, i8, i8, i8, i8 } }, ptr null, i32 1) to i64))57// CHECK:         %[[VAL_6:.*]] = getelementptr { { ptr, i64, i32, i8, i8, i8, i8 }, { ptr, i64, i32, i8, i8, i8, i8 } }, ptr %[[VAL_5]], i32 0, i32 058// CHECK:         %[[VAL_7:.*]] = getelementptr { { ptr, i64, i32, i8, i8, i8, i8 }, { ptr, i64, i32, i8, i8, i8, i8 } }, ptr %[[VAL_5]], i32 0, i32 159// ...60// CHECK:         br label %[[VAL_9:.*]]61// CHECK:       omp.private.init4:                                ; preds = %[[VAL_10:.*]], %[[VAL_11:.*]]62// CHECK:         br label %[[VAL_12:.*]]63// CHECK:       omp.private.init3:                                ; preds = %[[VAL_9]]64// CHECK:         br label %[[VAL_13:.*]]65// CHECK:       omp.private.init2:                                ; preds = %[[VAL_9]]66// CHECK:         br label %[[VAL_13]]67// CHECK:       omp.private.init1:                                ; preds = %[[VAL_4]]68// CHECK:         %[[VAL_14:.*]] = alloca { ptr, i64, i32, i8, i8, i8, i8 }, align 869// CHECK:         call void @llvm.memcpy.p0.p0.i32(ptr %[[VAL_14]], ptr %[[VAL_0]], i32 24, i1 false)70// CHECK:         %[[VAL_15:.*]] = ptrtoint ptr %[[VAL_0]] to i6471// CHECK:         %[[VAL_16:.*]] = icmp eq i64 %[[VAL_15]], 072// CHECK:         br i1 %[[VAL_16]], label %[[VAL_10]], label %[[VAL_11]]73// CHECK:       omp.region.cont:                                  ; preds = %[[VAL_13]]74// CHECK:         %[[VAL_17:.*]] = phi ptr [ %[[VAL_7]], %[[VAL_13]] ]75// CHECK:         br label %[[VAL_18:.*]]76// CHECK:       omp.private.copy:                                 ; preds = %[[VAL_12]]77// CHECK:         br label %[[VAL_19:.*]]78// CHECK:       omp.task.start:                                   ; preds = %[[VAL_18]]79// CHECK:         br label %[[VAL_20:.*]]80// CHECK:       codeRepl:                                         ; preds = %[[VAL_19]]81// CHECK:         %[[VAL_21:.*]] = getelementptr { ptr }, ptr %[[STRUCTARG]], i32 0, i32 082// CHECK:         store ptr %[[VAL_5]], ptr %[[VAL_21]], align 883// CHECK:         %[[VAL_22:.*]] = call i32 @__kmpc_global_thread_num(ptr @1)84// CHECK:         %[[VAL_23:.*]] = call ptr @__kmpc_omp_task_alloc(ptr @1, i32 %[[VAL_22]], i32 1, i64 40, i64 8, ptr @_QQmain..omp_par)85// CHECK:         %[[VAL_24:.*]] = load ptr, ptr %[[VAL_23]], align 886// CHECK:         call void @llvm.memcpy.p0.p0.i64(ptr align 1 %[[VAL_24]], ptr align 1 %[[STRUCTARG]], i64 8, i1 false)87// CHECK:         %[[VAL_25:.*]] = call i32 @__kmpc_omp_task(ptr @1, i32 %[[VAL_22]], ptr %[[VAL_23]])88