1 ; RUN: opt < %s -functionattrs -S | FileCheck %s
2 ; RUN: opt < %s -passes=function-attrs -S | FileCheck %s
4 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
5 target triple = "x86_64-unknown-linux-gnu"
7 ; CHECK: define void @_Z4foo1Pi(i32* nocapture readnone %a) local_unnamed_addr #0 {
8 define void @_Z4foo1Pi(i32* nocapture readnone %a) local_unnamed_addr #0 {
10 tail call void @_Z3extv()
14 declare void @_Z3extv() local_unnamed_addr
16 ; CHECK: define void @_Z4foo2Pi(i32* nocapture %a) local_unnamed_addr #1 {
17 define void @_Z4foo2Pi(i32* nocapture %a) local_unnamed_addr #1 {
19 %0 = bitcast i32* %a to i8*
20 tail call void @free(i8* %0) #2
24 declare void @free(i8* nocapture) local_unnamed_addr #2
26 ; CHECK: define i32 @_Z4foo3Pi(i32* nocapture readonly %a) local_unnamed_addr #3 {
27 define i32 @_Z4foo3Pi(i32* nocapture readonly %a) local_unnamed_addr #3 {
29 %0 = load i32, i32* %a, align 4
33 ; CHECK: define double @_Z4foo4Pd(double* nocapture readonly %a) local_unnamed_addr #1 {
34 define double @_Z4foo4Pd(double* nocapture readonly %a) local_unnamed_addr #1 {
36 %0 = load double, double* %a, align 8
37 %call = tail call double @cos(double %0) #2
41 declare double @cos(double) local_unnamed_addr #2
43 ; CHECK: define noalias i32* @_Z4foo5Pm(i64* nocapture readonly %a) local_unnamed_addr #1 {
44 define noalias i32* @_Z4foo5Pm(i64* nocapture readonly %a) local_unnamed_addr #1 {
46 %0 = load i64, i64* %a, align 8
47 %call = tail call noalias i8* @malloc(i64 %0) #2
48 %1 = bitcast i8* %call to i32*
52 declare noalias i8* @malloc(i64) local_unnamed_addr #2
54 ; CHECK: define noalias i64* @_Z4foo6Pm(i64* nocapture %a) local_unnamed_addr #1 {
55 define noalias i64* @_Z4foo6Pm(i64* nocapture %a) local_unnamed_addr #1 {
57 %0 = bitcast i64* %a to i8*
58 %1 = load i64, i64* %a, align 8
59 %call = tail call i8* @realloc(i8* %0, i64 %1) #2
60 %2 = bitcast i8* %call to i64*
64 declare noalias i8* @realloc(i8* nocapture, i64) local_unnamed_addr #2
66 ; CHECK: define void @_Z4foo7Pi(i32* %a) local_unnamed_addr #1 {
67 define void @_Z4foo7Pi(i32* %a) local_unnamed_addr #1 {
69 %isnull = icmp eq i32* %a, null
70 br i1 %isnull, label %delete.end, label %delete.notnull
72 delete.notnull: ; preds = %entry
73 %0 = bitcast i32* %a to i8*
74 tail call void @_ZdlPv(i8* %0) #5
77 delete.end: ; preds = %delete.notnull, %entry
81 declare void @_ZdlPv(i8*) local_unnamed_addr #4
83 ; CHECK: define void @_Z4foo8Pi(i32* %a) local_unnamed_addr #1 {
84 define void @_Z4foo8Pi(i32* %a) local_unnamed_addr #1 {
86 %isnull = icmp eq i32* %a, null
87 br i1 %isnull, label %delete.end, label %delete.notnull
89 delete.notnull: ; preds = %entry
90 %0 = bitcast i32* %a to i8*
91 tail call void @_ZdaPv(i8* %0) #5
94 delete.end: ; preds = %delete.notnull, %entry
98 declare void @_ZdaPv(i8*) local_unnamed_addr #4
100 attributes #0 = { uwtable }
101 attributes #1 = { nounwind uwtable }
102 attributes #2 = { nounwind }
103 attributes #3 = { norecurse nounwind readonly uwtable }
104 attributes #4 = { nobuiltin nounwind }
105 attributes #5 = { builtin nounwind }
107 ; CHECK: attributes #0 = { uwtable }
108 ; CHECK: attributes #1 = { nounwind uwtable }
109 ; CHECK: attributes #2 = { nounwind }
110 ; CHECK: attributes #3 = { norecurse nounwind readonly uwtable }
111 ; CHECK: attributes #4 = { nobuiltin nounwind }
112 ; CHECK: attributes #5 = { builtin nounwind }