| ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6 |
| ; RUN: opt -passes='require<profile-summary>,function(codegenprepare)' -S -mtriple=x86_64 < %s | FileCheck %s |
| |
| ; Test that SplitIndirectBrCriticalEdges does not crash when a predecessor |
| ; block has a conditional branch with both targets pointing to the same |
| ; destination (producing duplicate entries in the predecessor list). |
| |
| |
| define i32 @duplicate_pred_condbr(ptr %addr, i1 %cond) { |
| ; CHECK-LABEL: define i32 @duplicate_pred_condbr( |
| ; CHECK-SAME: ptr [[ADDR:%.*]], i1 [[COND:%.*]]) { |
| ; CHECK-NEXT: [[ENTRY:.*:]] |
| ; CHECK-NEXT: indirectbr ptr [[ADDR]], [label %[[TARGET:.*]], label %[[COND_BB:.*]]] |
| ; CHECK: [[COND_BB]]: |
| ; CHECK-NEXT: br [[DOTSPLIT:label %.*]] |
| ; CHECK: [[TARGET]]: |
| ; CHECK-NEXT: br [[DOTSPLIT]] |
| ; CHECK: [[_SPLIT:.*:]] |
| ; CHECK-NEXT: [[MERGE:%.*]] = phi i32 [ 0, %[[TARGET]] ], [ 1, %[[COND_BB]] ] |
| ; CHECK-NEXT: ret i32 [[MERGE]] |
| ; |
| entry: |
| indirectbr ptr %addr, [label %target, label %cond.bb] |
| |
| cond.bb: |
| br i1 %cond, label %target, label %target |
| |
| target: |
| %result = phi i32 [ 0, %entry ], [ 1, %cond.bb ], [ 1, %cond.bb ] |
| ret i32 %result |
| } |