1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
2 ; RUN: opt -S -passes=newgvn < %s | FileCheck %s
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"
8 declare ptr @malloc(i64) nounwind allockind("alloc,uninitialized") allocsize(0) "alloc-family"="malloc"
10 define noalias ptr @test1() nounwind uwtable ssp {
11 ; CHECK-LABEL: define noalias ptr @test1(
12 ; CHECK-SAME: ) #[[ATTR1:[0-9]+]] {
14 ; CHECK-NEXT: [[CALL:%.*]] = tail call ptr @malloc(i64 100) #[[ATTR2:[0-9]+]]
15 ; CHECK-NEXT: br i1 undef, label [[IF_END:%.*]], label [[IF_THEN:%.*]]
17 ; CHECK-NEXT: store i8 0, ptr [[CALL]], align 1
18 ; CHECK-NEXT: br label [[IF_END]]
20 ; CHECK-NEXT: ret ptr [[CALL]]
23 %call = tail call ptr @malloc(i64 100) nounwind
24 %0 = load i8, ptr %call, align 1
25 %tobool = icmp eq i8 %0, 0
26 br i1 %tobool, label %if.end, label %if.then
28 if.then: ; preds = %entry
29 store i8 0, ptr %call, align 1
32 if.end: ; preds = %if.then, %entry
37 declare ptr @_Znwm(i64) nounwind
39 define noalias ptr @test2() nounwind uwtable ssp {
40 ; CHECK-LABEL: define noalias ptr @test2(
41 ; CHECK-SAME: ) #[[ATTR1]] {
43 ; CHECK-NEXT: [[CALL:%.*]] = tail call ptr @_Znwm(i64 100) #[[ATTR2]]
44 ; CHECK-NEXT: br i1 undef, label [[IF_END:%.*]], label [[IF_THEN:%.*]]
46 ; CHECK-NEXT: store i8 0, ptr [[CALL]], align 1
47 ; CHECK-NEXT: br label [[IF_END]]
49 ; CHECK-NEXT: ret ptr [[CALL]]
52 %call = tail call ptr @_Znwm(i64 100) nounwind
53 %0 = load i8, ptr %call, align 1
54 %tobool = icmp eq i8 %0, 0
55 br i1 %tobool, label %if.end, label %if.then
57 if.then: ; preds = %entry
58 store i8 0, ptr %call, align 1
61 if.end: ; preds = %if.then, %entry
66 declare ptr @aligned_alloc(i64 allocalign, i64) nounwind allockind("alloc,uninitialized,aligned") allocsize(1) "alloc-family"="malloc"
68 define noalias ptr @test3() nounwind uwtable ssp {
69 ; CHECK-LABEL: define noalias ptr @test3(
70 ; CHECK-SAME: ) #[[ATTR1]] {
72 ; CHECK-NEXT: [[CALL:%.*]] = tail call ptr @aligned_alloc(i64 256, i64 32) #[[ATTR2]]
73 ; CHECK-NEXT: br i1 undef, label [[IF_END:%.*]], label [[IF_THEN:%.*]]
75 ; CHECK-NEXT: store i8 0, ptr [[CALL]], align 1
76 ; CHECK-NEXT: br label [[IF_END]]
78 ; CHECK-NEXT: ret ptr [[CALL]]
81 %call = tail call ptr @aligned_alloc(i64 256, i64 32) nounwind
82 %0 = load i8, ptr %call, align 32
83 %tobool = icmp eq i8 %0, 0
84 br i1 %tobool, label %if.end, label %if.then
86 if.then: ; preds = %entry
87 store i8 0, ptr %call, align 1
90 if.end: ; preds = %if.then, %entry