1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-attributes
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 define void @_Z4foo1Pi(ptr nocapture readnone %a) local_unnamed_addr #0 {
8 ; CHECK: Function Attrs: uwtable
9 ; CHECK-LABEL: @_Z4foo1Pi(
11 ; CHECK-NEXT: tail call void @_Z3extv()
12 ; CHECK-NEXT: ret void
15 tail call void @_Z3extv()
19 declare void @_Z3extv() local_unnamed_addr
21 define void @_Z4foo2Pi(ptr nocapture %a) local_unnamed_addr #1 {
22 ; CHECK: Function Attrs: nounwind uwtable
23 ; CHECK-LABEL: @_Z4foo2Pi(
25 ; CHECK-NEXT: tail call void @free(ptr [[A:%.*]]) #[[ATTR2:[0-9]+]]
26 ; CHECK-NEXT: ret void
29 tail call void @free(ptr %a) #2
33 declare void @free(ptr nocapture) local_unnamed_addr #2
35 define i32 @_Z4foo3Pi(ptr nocapture readonly %a) local_unnamed_addr #3 {
36 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
37 ; CHECK-LABEL: @_Z4foo3Pi(
39 ; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A:%.*]], align 4
40 ; CHECK-NEXT: ret i32 [[TMP0]]
43 %0 = load i32, ptr %a, align 4
47 define double @_Z4foo4Pd(ptr nocapture readonly %a) local_unnamed_addr #1 {
48 ; CHECK: Function Attrs: nounwind uwtable
49 ; CHECK-LABEL: @_Z4foo4Pd(
51 ; CHECK-NEXT: [[TMP0:%.*]] = load double, ptr [[A:%.*]], align 8
52 ; CHECK-NEXT: [[CALL:%.*]] = tail call double @cos(double [[TMP0]]) #[[ATTR2]]
53 ; CHECK-NEXT: ret double [[CALL]]
56 %0 = load double, ptr %a, align 8
57 %call = tail call double @cos(double %0) #2
61 declare double @cos(double) local_unnamed_addr #2
63 define noalias ptr @_Z4foo5Pm(ptr nocapture readonly %a) local_unnamed_addr #1 {
64 ; CHECK: Function Attrs: nounwind uwtable
65 ; CHECK-LABEL: @_Z4foo5Pm(
67 ; CHECK-NEXT: [[TMP0:%.*]] = load i64, ptr [[A:%.*]], align 8
68 ; CHECK-NEXT: [[CALL:%.*]] = tail call noalias ptr @malloc(i64 [[TMP0]]) #[[ATTR2]]
69 ; CHECK-NEXT: ret ptr [[CALL]]
72 %0 = load i64, ptr %a, align 8
73 %call = tail call noalias ptr @malloc(i64 %0) #2
77 declare noalias ptr @malloc(i64) local_unnamed_addr #2
79 define noalias ptr @_Z4foo6Pm(ptr nocapture %a) local_unnamed_addr #1 {
80 ; CHECK: Function Attrs: nounwind uwtable
81 ; CHECK-LABEL: @_Z4foo6Pm(
83 ; CHECK-NEXT: [[TMP0:%.*]] = load i64, ptr [[A:%.*]], align 8
84 ; CHECK-NEXT: [[CALL:%.*]] = tail call ptr @realloc(ptr [[A]], i64 [[TMP0]]) #[[ATTR2]]
85 ; CHECK-NEXT: ret ptr [[CALL]]
88 %0 = load i64, ptr %a, align 8
89 %call = tail call ptr @realloc(ptr %a, i64 %0) #2
93 declare noalias ptr @realloc(ptr nocapture, i64) local_unnamed_addr #2
95 define void @_Z4foo7Pi(ptr %a) local_unnamed_addr #1 {
96 ; CHECK: Function Attrs: nounwind uwtable
97 ; CHECK-LABEL: @_Z4foo7Pi(
99 ; CHECK-NEXT: [[ISNULL:%.*]] = icmp eq ptr [[A:%.*]], null
100 ; CHECK-NEXT: br i1 [[ISNULL]], label [[DELETE_END:%.*]], label [[DELETE_NOTNULL:%.*]]
101 ; CHECK: delete.notnull:
102 ; CHECK-NEXT: tail call void @_ZdlPv(ptr [[A]]) #[[ATTR6:[0-9]+]]
103 ; CHECK-NEXT: br label [[DELETE_END]]
105 ; CHECK-NEXT: ret void
108 %isnull = icmp eq ptr %a, null
109 br i1 %isnull, label %delete.end, label %delete.notnull
111 delete.notnull: ; preds = %entry
112 tail call void @_ZdlPv(ptr %a) #5
115 delete.end: ; preds = %delete.notnull, %entry
119 declare void @_ZdlPv(ptr) local_unnamed_addr #4
121 define void @_Z4foo8Pi(ptr %a) local_unnamed_addr #1 {
122 ; CHECK: Function Attrs: nounwind uwtable
123 ; CHECK-LABEL: @_Z4foo8Pi(
125 ; CHECK-NEXT: [[ISNULL:%.*]] = icmp eq ptr [[A:%.*]], null
126 ; CHECK-NEXT: br i1 [[ISNULL]], label [[DELETE_END:%.*]], label [[DELETE_NOTNULL:%.*]]
127 ; CHECK: delete.notnull:
128 ; CHECK-NEXT: tail call void @_ZdaPv(ptr [[A]]) #[[ATTR6]]
129 ; CHECK-NEXT: br label [[DELETE_END]]
131 ; CHECK-NEXT: ret void
134 %isnull = icmp eq ptr %a, null
135 br i1 %isnull, label %delete.end, label %delete.notnull
137 delete.notnull: ; preds = %entry
138 tail call void @_ZdaPv(ptr %a) #5
141 delete.end: ; preds = %delete.notnull, %entry
145 declare void @may_free()
147 define void @nofree_callsite_attr(ptr %a) {
148 ; CHECK: Function Attrs: nofree
149 ; CHECK-LABEL: @nofree_callsite_attr(
151 ; CHECK-NEXT: call void @may_free() #[[ATTR5:[0-9]+]]
152 ; CHECK-NEXT: ret void
155 call void @may_free() nofree
159 declare void @_ZdaPv(ptr) local_unnamed_addr #4
161 attributes #0 = { uwtable }
162 attributes #1 = { nounwind uwtable }
163 attributes #2 = { nounwind }
164 attributes #3 = { norecurse nounwind readonly uwtable }
165 attributes #4 = { nobuiltin nounwind }
166 attributes #5 = { builtin nounwind }