1 ; RUN: opt -S -basicaa -gvn < %s | FileCheck %s 2 ; RUN: opt -S -basicaa -gvn -disable-simplify-libcalls < %s | FileCheck %s -check-prefix=CHECK_NO_LIBCALLS 3 ; PR13694 4 5 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" 6 target triple = "x86_64-apple-macosx10.8.0" 7 8 declare i8* @malloc(i64) nounwind 9 10 define noalias i8* @test1() nounwind uwtable ssp { 11 entry: 12 %call = tail call i8* @malloc(i64 100) nounwind 13 %0 = load i8, i8* %call, align 1 14 %tobool = icmp eq i8 %0, 0 15 br i1 %tobool, label %if.end, label %if.then 16 17 if.then: ; preds = %entry 18 store i8 0, i8* %call, align 1 19 br label %if.end 20 21 if.end: ; preds = %if.then, %entry 22 ret i8* %call 23 24 ; CHECK-LABEL: @test1( 25 ; CHECK-NOT: load 26 ; CHECK-NOT: icmp 27 28 ; CHECK_NO_LIBCALLS-LABEL: @test1( 29 ; CHECK_NO_LIBCALLS: load 30 ; CHECK_NO_LIBCALLS: icmp 31 } 32 33 declare i8* @_Znwm(i64) nounwind 34 35 define noalias i8* @test2() nounwind uwtable ssp { 36 entry: 37 %call = tail call i8* @_Znwm(i64 100) nounwind 38 %0 = load i8, i8* %call, align 1 39 %tobool = icmp eq i8 %0, 0 40 br i1 %tobool, label %if.end, label %if.then 41 42 if.then: ; preds = %entry 43 store i8 0, i8* %call, align 1 44 br label %if.end 45 46 if.end: ; preds = %if.then, %entry 47 ret i8* %call 48 49 ; CHECK-LABEL: @test2( 50 ; CHECK-NOT: load 51 ; CHECK-NOT: icmp 52 53 ; CHECK_NO_LIBCALLS-LABEL: @test2( 54 ; CHECK_NO_LIBCALLS: load 55 ; CHECK_NO_LIBCALLS: icmp 56 } 57