brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.2 KiB · 3280625 Raw
108 lines · plain
1; RUN: mlir-translate -import-llvm -split-input-file %s | FileCheck %s2 3; CHECK-LABEL: @cond_br4define i64 @cond_br(i1 %arg1, i64 %arg2) {5entry:6  ; CHECK: llvm.cond_br7  ; CHECK-SAME: weights([0, 3])8  br i1 %arg1, label %bb1, label %bb2, !prof !09bb1:10  ret i64 %arg211bb2:12  ret i64 %arg213}14 15!0 = !{!"branch_weights", i32 0, i32 3}16 17; // -----18 19; CHECK-LABEL: @cond_br_expected20define i64 @cond_br_expected(i1 %arg1, i64 %arg2) {21entry:22  ; CHECK: llvm.cond_br23  ; CHECK-SAME: weights([1, 2000])24  br i1 %arg1, label %bb1, label %bb2, !prof !025bb1:26  ret i64 %arg227bb2:28  ret i64 %arg229}30 31!0 = !{!"branch_weights", !"expected", i32 1, i32 2000}32 33; // -----34 35; CHECK-LABEL: @simple_switch(36define i32 @simple_switch(i32 %arg1) {37  ; CHECK: llvm.switch38  ; CHECK: {branch_weights = array<i32: 42, 3, 5>}39  switch i32 %arg1, label %bbd [40    i32 0, label %bb141    i32 9, label %bb242  ], !prof !043bb1:44  ret i32 %arg145bb2:46  ret i32 %arg147bbd:48  ret i32 %arg149}50 51!0 = !{!"branch_weights", i32 42, i32 3, i32 5}52 53; // -----54 55; CHECK-LABEL: @simple_switch_expected(56define i32 @simple_switch_expected(i32 %arg1) {57  ; CHECK: llvm.switch58  ; CHECK: {branch_weights = array<i32: 1, 1, 2000>}59  switch i32 %arg1, label %bbd [60    i32 0, label %bb161    i32 9, label %bb262  ], !prof !063bb1:64  ret i32 %arg165bb2:66  ret i32 %arg167bbd:68  ret i32 %arg169}70 71!0 = !{!"branch_weights", !"expected", i32 1, i32 1, i32 2000}72 73; // -----74 75; Verify that a single weight attached to a call is not translated.76; The MLIR WeightedBranchOpInterface does not support this case.77 78; CHECK: llvm.func @fn()79declare i32 @fn()80 81; CHECK-LABEL: @call_branch_weights82define i32 @call_branch_weights() {83  ; CHECK:  llvm.call @fn() : () -> i3284  %1 = call i32 @fn(), !prof !085  ret i32 %186}87 88!0 = !{!"branch_weights", i32 42}89 90; // -----91 92declare void @foo()93declare i32 @__gxx_personality_v0(...)94 95; CHECK-LABEL: @invoke_branch_weights96define i32 @invoke_branch_weights() personality ptr @__gxx_personality_v0 {97  ; CHECK: llvm.invoke @foo() to ^bb2 unwind ^bb1 {branch_weights = array<i32: 42, 99>} : () -> ()98  invoke void @foo() to label %bb2 unwind label %bb1, !prof !099bb1:100  %1 = landingpad { ptr, i32 } cleanup101  br label %bb2102bb2:103  ret i32 1104 105}106 107!0 = !{!"branch_weights", i32 42, i32 99}108