| Benjamin Kramer | 8bcc971 | 2012-08-29 15:32:21 +0000 | [diff] [blame] | 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 |  | 
| Benjamin Kramer | 2939dd3 | 2013-09-24 17:34:29 +0000 | [diff] [blame] | 10 | define noalias i8* @test1() nounwind uwtable ssp { | 
| Benjamin Kramer | 8bcc971 | 2012-08-29 15:32:21 +0000 | [diff] [blame] | 11 | entry: | 
|  | 12 | %call = tail call i8* @malloc(i64 100) nounwind | 
| David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 13 | %0 = load i8, i8* %call, align 1 | 
| Benjamin Kramer | 8bcc971 | 2012-08-29 15:32:21 +0000 | [diff] [blame] | 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 |  | 
| Benjamin Kramer | 2939dd3 | 2013-09-24 17:34:29 +0000 | [diff] [blame] | 24 | ; CHECK-LABEL: @test1( | 
| Benjamin Kramer | 8bcc971 | 2012-08-29 15:32:21 +0000 | [diff] [blame] | 25 | ; CHECK-NOT: load | 
|  | 26 | ; CHECK-NOT: icmp | 
|  | 27 |  | 
| Benjamin Kramer | 2939dd3 | 2013-09-24 17:34:29 +0000 | [diff] [blame] | 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 | 
| David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 38 | %0 = load i8, i8* %call, align 1 | 
| Benjamin Kramer | 2939dd3 | 2013-09-24 17:34:29 +0000 | [diff] [blame] | 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( | 
| Benjamin Kramer | 8bcc971 | 2012-08-29 15:32:21 +0000 | [diff] [blame] | 54 | ; CHECK_NO_LIBCALLS: load | 
|  | 55 | ; CHECK_NO_LIBCALLS: icmp | 
|  | 56 | } |