Home | History | Annotate | Download | only in FunctionAttrs
      1 ; RUN: opt < %s -basicaa -functionattrs -rpo-functionattrs -S | FileCheck %s
      2 ; RUN: opt < %s -aa-pipeline=basic-aa -passes='cgscc(function-attrs),rpo-functionattrs' -S | FileCheck %s
      3 
      4 ; CHECK: define i32 @leaf() #0
      5 define i32 @leaf() {
      6   ret i32 1
      7 }
      8 
      9 ; CHECK: define i32 @self_rec() #1
     10 define i32 @self_rec() {
     11   %a = call i32 @self_rec()
     12   ret i32 4
     13 }
     14 
     15 ; CHECK: define i32 @indirect_rec() #1
     16 define i32 @indirect_rec() {
     17   %a = call i32 @indirect_rec2()
     18   ret i32 %a
     19 }
     20 ; CHECK: define i32 @indirect_rec2() #1
     21 define i32 @indirect_rec2() {
     22   %a = call i32 @indirect_rec()
     23   ret i32 %a
     24 }
     25 
     26 ; CHECK: define i32 @extern() #1
     27 define i32 @extern() {
     28   %a = call i32 @k()
     29   ret i32 %a
     30 }
     31 declare i32 @k() readnone
     32 
     33 ; CHECK: define void @intrinsic(i8* nocapture %dest, i8* nocapture readonly %src, i32 %len) {
     34 define void @intrinsic(i8* %dest, i8* %src, i32 %len) {
     35   call void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 %len, i32 1, i1 false)
     36   ret void
     37 }
     38 declare void @llvm.memcpy.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1)
     39 
     40 ; CHECK: define internal i32 @called_by_norecurse() #0
     41 define internal i32 @called_by_norecurse() {
     42   %a = call i32 @k()
     43   ret i32 %a
     44 }
     45 define void @m() norecurse {
     46   %a = call i32 @called_by_norecurse()
     47   ret void
     48 }
     49 
     50 ; CHECK: define internal i32 @called_by_norecurse_indirectly() #0
     51 define internal i32 @called_by_norecurse_indirectly() {
     52   %a = call i32 @k()
     53   ret i32 %a
     54 }
     55 define internal void @o() {
     56   %a = call i32 @called_by_norecurse_indirectly()
     57   ret void
     58 }
     59 define void @p() norecurse {
     60   call void @o()
     61   ret void
     62 }
     63 
     64 ; CHECK: attributes #0 = { norecurse readnone }
     65 ; CHECK: attributes #1 = { readnone }
     66