1 ; RUN: opt -S -attributor -attributor-disable=false < %s | FileCheck %s
12 @G = external global i8*
14 ; CHECK: define i8* @foo()
16 %1 = tail call noalias i8* @malloc(i64 4)
17 store i8* %1, i8** @G, align 8
21 declare noalias i8* @malloc(i64)
24 ; call noalias function in return instruction.
26 ; CHECK: define noalias i8* @return_noalias()
27 define i8* @return_noalias(){
28 %1 = tail call noalias i8* @malloc(i64 4)
35 ; CHECK: define i8* @call_alias()
37 define i8* @call_alias(){
38 %1 = tail call i8* @alias()
57 ; CHECK: define i8* @bar()
58 define i8* @bar() nounwind uwtable {
59 %1 = tail call i8* (...) @baz()
63 ; CHECK: define noalias i8* @foo1(i32 %0)
64 define i8* @foo1(i32 %0) nounwind uwtable {
65 %2 = icmp eq i32 %0, 0
66 br i1 %2, label %5, label %3
69 %4 = tail call i8* (...) @baz()
73 %6 = tail call noalias i8* @malloc(i64 4)
77 declare i8* @baz(...) nounwind uwtable
81 ; Returning global pointer. Should not be noalias.
82 ; CHECK: define nonnull align 8 dereferenceable(8) i8** @getter()
83 define i8** @getter() {
87 ; Returning global pointer. Should not be noalias.
88 ; CHECK: define nonnull align 8 dereferenceable(8) i8** @calle1()
89 define i8** @calle1(){
90 %1 = call i8** @getter()
95 declare noalias i8* @strdup(i8* nocapture) nounwind
97 ; CHECK: define noalias i8* @test6()
98 define i8* @test6() nounwind uwtable ssp {
99 %x = alloca [2 x i8], align 1
100 %arrayidx = getelementptr inbounds [2 x i8], [2 x i8]* %x, i64 0, i64 0
101 store i8 97, i8* %arrayidx, align 1
102 %arrayidx1 = getelementptr inbounds [2 x i8], [2 x i8]* %x, i64 0, i64 1
103 store i8 0, i8* %arrayidx1, align 1
104 %call = call noalias i8* @strdup(i8* %arrayidx) nounwind
110 ; CHECK: define noalias i8* @test7()
111 define i8* @test7() nounwind {
113 %A = call noalias i8* @malloc(i64 4) nounwind
114 %tobool = icmp eq i8* %A, null
115 br i1 %tobool, label %return, label %if.end
122 %retval.0 = phi i8* [ %A, %if.end ], [ null, %entry ]
128 ; CHECK: define noalias i8* @test8(i32* %0)
129 define i8* @test8(i32* %0) nounwind uwtable {
130 %2 = tail call noalias i8* @malloc(i64 4)
131 %3 = icmp ne i32* %0, null
132 br i1 %3, label %4, label %5