49 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature2; RUN: opt -S -O3 -o - %s | FileCheck %s3 4; PR44154: LLVM c3b06d0c393e caused the body of @main to be replaced with5; unreachable. Check that we perform the expected calls and optimizations.6 7target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"8target triple = "x86_64-unknown-linux-gnu"9 10define i32 @main(i32 %argc, ptr %argv) #0 {11; CHECK-LABEL: define {{[^@]+}}@main12; CHECK-SAME: (i32 [[ARGC:%.*]], ptr readonly captures(none) [[ARGV:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {13; CHECK-NEXT: entry:14; CHECK-NEXT: [[TMP0:%.*]] = icmp slt i32 [[ARGC]], 215; CHECK-NEXT: [[SPEC_SELECT:%.*]] = select i1 [[TMP0]], i32 0, i32 [[ARGC]]16; CHECK-NEXT: ret i32 [[SPEC_SELECT]]17;18entry:19 %ptr = load ptr, ptr %argv20 %0 = call i32 @compute(ptr %ptr, i32 %argc)21 %1 = icmp slt i32 %argc, 222 br i1 %1, label %done, label %do_work23 24do_work:25 %2 = icmp eq ptr %ptr, null26 br i1 %2, label %null, label %done27 28null:29 call void @call_if_null(ptr %ptr)30 br label %done31 32done:33 %retval = phi i32 [0, %entry], [%0, %do_work], [%0, %null]34 ret i32 %retval35}36 37define i32 @compute(ptr noundef nonnull %ptr, i32 %x) #1 {38; CHECK-LABEL: define {{[^@]+}}@compute39; CHECK-SAME: (ptr noundef nonnull readnone captures(none) [[PTR:%.*]], i32 returned [[X:%.*]]) local_unnamed_addr #[[ATTR1:[0-9]+]] {40; CHECK-NEXT: ret i32 [[X]]41;42 ret i32 %x43}44 45declare void @call_if_null(ptr %ptr) #046 47attributes #0 = { nounwind }48attributes #1 = { noinline nounwind readonly }49