Skip to content

Commit

Permalink
[FunctionAttrs] Regenerate test checks (NFC)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikic committed Oct 12, 2022
1 parent cbae57c commit dbd29ed
Show file tree
Hide file tree
Showing 7 changed files with 232 additions and 106 deletions.
28 changes: 17 additions & 11 deletions llvm/test/Transforms/FunctionAttrs/2008-09-03-Mutual.ll
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
; RUN: opt < %s -function-attrs -S | FileCheck %s
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes
; RUN: opt < %s -passes=function-attrs -S | FileCheck %s

; CHECK: Function Attrs
; CHECK-SAME: readnone
; CHECK-NEXT: define i32 @a
define i32 @a() {
%tmp = call i32 @b( ) ; <i32> [#uses=1]
ret i32 %tmp
; CHECK: Function Attrs: nofree nosync nounwind readnone
; CHECK-LABEL: define {{[^@]+}}@a
; CHECK-SAME: () #[[ATTR0:[0-9]+]] {
; CHECK-NEXT: [[TMP:%.*]] = call i32 @b()
; CHECK-NEXT: ret i32 [[TMP]]
;
%tmp = call i32 @b()
ret i32 %tmp
}

; CHECK: Function Attrs
; CHECK-SAME: readnone
; CHECK-NEXT: define i32 @b
define i32 @b() {
%tmp = call i32 @a( ) ; <i32> [#uses=1]
ret i32 %tmp
; CHECK: Function Attrs: nofree nosync nounwind readnone
; CHECK-LABEL: define {{[^@]+}}@b
; CHECK-SAME: () #[[ATTR0]] {
; CHECK-NEXT: [[TMP:%.*]] = call i32 @a()
; CHECK-NEXT: ret i32 [[TMP]]
;
%tmp = call i32 @a()
ret i32 %tmp
}
40 changes: 21 additions & 19 deletions llvm/test/Transforms/FunctionAttrs/2008-09-03-ReadNone.ll
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
; RUN: opt < %s -function-attrs -S | FileCheck %s
; RUN: opt < %s -aa-pipeline=basic-aa -passes=function-attrs -S | FileCheck %s
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-attributes
; RUN: opt < %s -passes=function-attrs -S | FileCheck %s

@x = global i32 0

; CHECK: Function Attrs
; CHECK-SAME: readnone
; CHECK-NEXT: declare i32 @e
declare i32 @e() readnone

; CHECK: Function Attrs
; CHECK-SAME: readnone
; CHECK-NEXT: define i32 @f
define i32 @f() {
%tmp = call i32 @e( ) ; <i32> [#uses=1]
ret i32 %tmp
; CHECK: Function Attrs: nofree nosync readnone
; CHECK-LABEL: @f(
; CHECK-NEXT: [[TMP:%.*]] = call i32 @e()
; CHECK-NEXT: ret i32 [[TMP]]
;
%tmp = call i32 @e()
ret i32 %tmp
}

; CHECK: Function Attrs
; CHECK-SAME: readnone
; CHECK-NEXT: define i32 @g
define i32 @g() readonly {
ret i32 0
; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
; CHECK-LABEL: @g(
; CHECK-NEXT: ret i32 0
;
ret i32 0
}

; CHECK: Function Attrs
; CHECK-SAME: readnone
; CHECK-NEXT: define i32 @h
define i32 @h() readnone {
%tmp = load i32, i32* @x ; <i32> [#uses=1]
ret i32 %tmp
; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
; CHECK-LABEL: @h(
; CHECK-NEXT: [[TMP:%.*]] = load i32, i32* @x, align 4
; CHECK-NEXT: ret i32 [[TMP]]
;
%tmp = load i32, i32* @x
ret i32 %tmp
}
14 changes: 8 additions & 6 deletions llvm/test/Transforms/FunctionAttrs/2008-09-03-ReadOnly.ll
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
; RUN: opt < %s -aa-pipeline=basic-aa -passes=function-attrs -S | FileCheck %s
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-attributes
; RUN: opt < %s -passes=function-attrs -S | FileCheck %s

; CHECK: define i32 @f() #0
define i32 @f() {
; CHECK: Function Attrs: nofree readonly
; CHECK-LABEL: @f(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[TMP:%.*]] = call i32 @e()
; CHECK-NEXT: ret i32 [[TMP]]
;
entry:
%tmp = call i32 @e( )
ret i32 %tmp
}

; CHECK: declare i32 @e() #1
declare i32 @e() readonly

; CHECK: attributes #0 = { nofree readonly }
; CHECK: attributes #1 = { readonly }
18 changes: 10 additions & 8 deletions llvm/test/Transforms/FunctionAttrs/2008-12-29-Constant.ll
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
; RUN: opt < %s -function-attrs -S | FileCheck %s
; RUN: opt < %s -aa-pipeline=basic-aa -passes=function-attrs -S | FileCheck %s
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-attributes
; RUN: opt < %s -passes=function-attrs -S | FileCheck %s

@s = external constant i8 ; <i8*> [#uses=1]
@s = external constant i8

; CHECK: define i8 @f() #0
define i8 @f() {
%tmp = load i8, i8* @s ; <i8> [#uses=1]
ret i8 %tmp
; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
; CHECK-LABEL: @f(
; CHECK-NEXT: [[TMP:%.*]] = load i8, i8* @s, align 1
; CHECK-NEXT: ret i8 [[TMP]]
;
%tmp = load i8, i8* @s
ret i8 %tmp
}

; CHECK: attributes #0 = { {{.*}} readnone
23 changes: 16 additions & 7 deletions llvm/test/Transforms/FunctionAttrs/atomic.ll
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
; RUN: opt -function-attrs -S < %s | FileCheck %s
; RUN: opt -aa-pipeline=basic-aa -passes=function-attrs -S < %s | FileCheck %s
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-attributes
; RUN: opt -passes=function-attrs -S < %s | FileCheck %s

; Atomic load/store to local doesn't affect whether a function is
; readnone/readonly.
define i32 @test1(i32 %x) uwtable ssp {
; CHECK: define i32 @test1(i32 %x) #0 {
; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind readnone ssp willreturn uwtable
; CHECK-LABEL: @test1(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[X_ADDR:%.*]] = alloca i32, align 4
; CHECK-NEXT: store atomic i32 [[X:%.*]], i32* [[X_ADDR]] seq_cst, align 4
; CHECK-NEXT: [[R:%.*]] = load atomic i32, i32* [[X_ADDR]] seq_cst, align 4
; CHECK-NEXT: ret i32 [[R]]
;
entry:
%x.addr = alloca i32, align 4
store atomic i32 %x, i32* %x.addr seq_cst, align 4
Expand All @@ -14,11 +21,13 @@ entry:

; A function with an Acquire load is not readonly.
define i32 @test2(i32* %x) uwtable ssp {
; CHECK: define i32 @test2(i32* nocapture readonly %x) #1 {
; CHECK: Function Attrs: argmemonly mustprogress nofree norecurse nounwind ssp willreturn uwtable
; CHECK-LABEL: @test2(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[R:%.*]] = load atomic i32, i32* [[X:%.*]] seq_cst, align 4
; CHECK-NEXT: ret i32 [[R]]
;
entry:
%r = load atomic i32, i32* %x seq_cst, align 4
ret i32 %r
}

; CHECK: attributes #0 = { mustprogress nofree norecurse nosync nounwind readnone ssp willreturn uwtable }
; CHECK: attributes #1 = { argmemonly mustprogress nofree norecurse nounwind ssp willreturn uwtable }
33 changes: 18 additions & 15 deletions llvm/test/Transforms/FunctionAttrs/int_sideeffect.ll
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
; RUN: opt -S < %s -function-attrs | FileCheck %s
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-attributes
; RUN: opt -S < %s -passes=function-attrs | FileCheck %s

; CHECK: Function Attrs
; CHECK-SAME: inaccessiblememonly
; CHECK-NEXT: declare void @llvm.sideeffect()
declare void @llvm.sideeffect()

; Don't add readnone or similar attributes when an @llvm.sideeffect() intrinsic
; is present.

; CHECK: Function Attrs
; CHECK-NOT: readnone
; CHECK: define void @test()
define void @test() {
call void @llvm.sideeffect()
ret void
; CHECK: Function Attrs: inaccessiblememonly mustprogress nofree nosync nounwind willreturn
; CHECK-LABEL: @test(
; CHECK-NEXT: call void @llvm.sideeffect()
; CHECK-NEXT: ret void
;
call void @llvm.sideeffect()
ret void
}

; CHECK: Function Attrs
; CHECK-NOT: readnone
; CHECK: define void @loop()
define void @loop() {
br label %loop
; CHECK: Function Attrs: inaccessiblememonly nofree noreturn nosync nounwind
; CHECK-LABEL: @loop(
; CHECK-NEXT: br label [[LOOP:%.*]]
; CHECK: loop:
; CHECK-NEXT: call void @llvm.sideeffect()
; CHECK-NEXT: br label [[LOOP]]
;
br label %loop

loop:
call void @llvm.sideeffect()
br label %loop
call void @llvm.sideeffect()
br label %loop
}

0 comments on commit dbd29ed

Please sign in to comment.