1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature
2 ; RUN: opt -S -O3 -o - %s | FileCheck %s
4 ; PR44154: LLVM c3b06d0c393e caused the body of @main to be replaced with
5 ; unreachable. Check that we perform the expected calls and optimizations.
7 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
8 target triple = "x86_64-unknown-linux-gnu"
10 define i32 @main(i32 %argc, ptr %argv) #0 {
11 ; CHECK-LABEL: define {{[^@]+}}@main
12 ; CHECK-SAME: (i32 [[ARGC:%.*]], ptr nocapture readonly [[ARGV:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
14 ; CHECK-NEXT: [[TMP0:%.*]] = icmp slt i32 [[ARGC]], 2
15 ; CHECK-NEXT: [[SPEC_SELECT:%.*]] = select i1 [[TMP0]], i32 0, i32 [[ARGC]]
16 ; CHECK-NEXT: ret i32 [[SPEC_SELECT]]
19 %ptr = load ptr, ptr %argv
20 %0 = call i32 @compute(ptr %ptr, i32 %argc)
21 %1 = icmp slt i32 %argc, 2
22 br i1 %1, label %done, label %do_work
25 %2 = icmp eq ptr %ptr, null
26 br i1 %2, label %null, label %done
29 call void @call_if_null(ptr %ptr)
33 %retval = phi i32 [0, %entry], [%0, %do_work], [%0, %null]
37 define i32 @compute(ptr noundef nonnull %ptr, i32 %x) #1 {
38 ; CHECK-LABEL: define {{[^@]+}}@compute
39 ; CHECK-SAME: (ptr nocapture noundef nonnull readnone [[PTR:%.*]], i32 returned [[X:%.*]]) local_unnamed_addr #[[ATTR1:[0-9]+]] {
40 ; CHECK-NEXT: ret i32 [[X]]
45 declare void @call_if_null(ptr %ptr) #0
47 attributes #0 = { nounwind }
48 attributes #1 = { noinline nounwind readonly }