1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature 2; RUN: opt < %s -S -passes=ipsccp | FileCheck %s 3 4; testf() performs an unconditional branch on poison, as such the testf() return 5; value used in test1() will remain "unknown" and the following branch on it 6; replaced by unreachable. This is fine, as the call to testf() will already 7; trigger undefined behavior. 8define void @test1() { 9; CHECK-LABEL: define {{[^@]+}}@test1() { 10; CHECK-NEXT: entry: 11; CHECK-NEXT: br label [[IF_THEN:%.*]] 12; CHECK: if.then: 13; CHECK-NEXT: [[CALL:%.*]] = call i1 @testf() 14; CHECK-NEXT: unreachable 15; 16entry: 17 br label %if.then 18if.then: ; preds = %entry, %if.then 19 %foo = phi i32 [ 0, %entry], [ %next, %if.then] 20 %next = add i32 %foo, 1 21 %call = call i1 @testf() 22 br i1 %call, label %if.end, label %if.then 23 24if.end: ; preds = %if.then, %entry 25 ret void 26} 27 28define internal i1 @testf() { 29; CHECK-LABEL: define {{[^@]+}}@testf() { 30; CHECK-NEXT: entry: 31; CHECK-NEXT: unreachable 32; 33entry: 34 br i1 poison, label %if.then1, label %if.end3 35 36if.then1: ; preds = %if.end 37 br label %if.end3 38 39if.end3: ; preds = %if.then1, %entry 40 ret i1 true 41} 42 43; Call sites in unreachable blocks should not be a problem. 44define i1 @test2() { 45; CHECK-LABEL: define {{[^@]+}}@test2() { 46; CHECK-NEXT: entry: 47; CHECK-NEXT: br label [[IF_END:%.*]] 48; CHECK: if.end: 49; CHECK-NEXT: [[CALL2:%.*]] = call i1 @testf() 50; CHECK-NEXT: ret i1 undef 51; 52entry: 53 br label %if.end 54 55if.then: ; preds = %entry, %if.then 56 %call = call i1 @testf() 57 br i1 %call, label %if.end, label %if.then 58 59if.end: ; preds = %if.then, %entry 60 %call2 = call i1 @testf() 61 ret i1 %call2 62} 63