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 13, 2022
1 parent 359bc5c commit 86126db
Show file tree
Hide file tree
Showing 6 changed files with 294 additions and 90 deletions.
27 changes: 17 additions & 10 deletions llvm/test/Transforms/FunctionAttrs/incompatible_fn_attrs.ll
@@ -1,32 +1,39 @@
; RUN: opt -S -o - -function-attrs %s | FileCheck %s
; RUN: opt -S -o - -passes=function-attrs %s | FileCheck %s
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-attributes
; RUN: opt -S -o - -passes=function-attrs < %s | FileCheck %s

; Verify we remove argmemonly/inaccessiblememonly/inaccessiblemem_or_argmemonly
; function attributes when we derive readnone.

; Function Attrs: argmemonly
define ptr @given_argmem_infer_readnone(ptr %p) #0 {
; CHECK: define ptr @given_argmem_infer_readnone(ptr readnone returned %p) #0 {
; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
; CHECK-LABEL: @given_argmem_infer_readnone(
; CHECK-NEXT: entry:
; CHECK-NEXT: ret ptr [[P:%.*]]
;
entry:
ret ptr %p
}

; Function Attrs: inaccessiblememonly
define ptr @given_inaccessible_infer_readnone(ptr %p) #1 {
; CHECK: define ptr @given_inaccessible_infer_readnone(ptr readnone returned %p) #0 {
; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
; CHECK-LABEL: @given_inaccessible_infer_readnone(
; CHECK-NEXT: entry:
; CHECK-NEXT: ret ptr [[P:%.*]]
;
entry:
ret ptr %p
}

; Function Attrs: inaccessiblemem_or_argmemonly
define ptr @given_inaccessible_or_argmem_infer_readnone(ptr %p) #2 {
; CHECK: define ptr @given_inaccessible_or_argmem_infer_readnone(ptr readnone returned %p) #0 {
; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
; CHECK-LABEL: @given_inaccessible_or_argmem_infer_readnone(
; CHECK-NEXT: entry:
; CHECK-NEXT: ret ptr [[P:%.*]]
;
entry:
ret ptr %p
}

attributes #0 = { argmemonly }
attributes #1 = { inaccessiblememonly }
attributes #2 = { inaccessiblemem_or_argmemonly }
; CHECK: attributes #0 = { mustprogress nofree norecurse nosync nounwind readnone willreturn }
; CHECK-NOT: attributes
66 changes: 52 additions & 14 deletions llvm/test/Transforms/FunctionAttrs/nounwind.ll
@@ -1,37 +1,51 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes
; RUN: opt < %s -function-attrs -S | FileCheck %s

; TEST 1
; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind readnone
; CHECK-NEXT: define i32 @foo1()
define i32 @foo1() {
; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
; CHECK-LABEL: define {{[^@]+}}@foo1
; CHECK-SAME: () #[[ATTR0:[0-9]+]] {
; CHECK-NEXT: ret i32 1
;
ret i32 1
}

; TEST 2
; CHECK: Function Attrs: nofree nosync nounwind readnone
; CHECK-NEXT: define i32 @scc1_foo()
define i32 @scc1_foo() {
; CHECK: Function Attrs: nofree nosync nounwind readnone
; CHECK-LABEL: define {{[^@]+}}@scc1_foo
; CHECK-SAME: () #[[ATTR1:[0-9]+]] {
; CHECK-NEXT: [[TMP1:%.*]] = call i32 @scc1_bar()
; CHECK-NEXT: ret i32 1
;
%1 = call i32 @scc1_bar()
ret i32 1
}


; TEST 3
; CHECK: Function Attrs: nofree nosync nounwind readnone
; CHECK-NEXT: define i32 @scc1_bar()
define i32 @scc1_bar() {
; CHECK: Function Attrs: nofree nosync nounwind readnone
; CHECK-LABEL: define {{[^@]+}}@scc1_bar
; CHECK-SAME: () #[[ATTR1]] {
; CHECK-NEXT: [[TMP1:%.*]] = call i32 @scc1_foo()
; CHECK-NEXT: ret i32 1
;
%1 = call i32 @scc1_foo()
ret i32 1
}

; CHECK: declare i32 @non_nounwind()
declare i32 @non_nounwind()

; TEST 4
; CHECK: define void @call_non_nounwind() {
define void @call_non_nounwind(){
tail call i32 @non_nounwind()
ret void
; CHECK-LABEL: define {{[^@]+}}@call_non_nounwind() {
; CHECK-NEXT: [[TMP1:%.*]] = tail call i32 @non_nounwind()
; CHECK-NEXT: ret void
;
tail call i32 @non_nounwind()
ret void
}

; TEST 5 - throw
Expand All @@ -42,8 +56,16 @@ define void @call_non_nounwind(){
; return -1;
; }

; CHECK: define i32 @maybe_throw(i1 zeroext %0)
define i32 @maybe_throw(i1 zeroext %0) {
; CHECK-LABEL: define {{[^@]+}}@maybe_throw
; CHECK-SAME: (i1 zeroext [[TMP0:%.*]]) {
; CHECK-NEXT: br i1 [[TMP0]], label [[TMP2:%.*]], label [[TMP3:%.*]]
; CHECK: 2:
; CHECK-NEXT: tail call void @__cxa_rethrow()
; CHECK-NEXT: unreachable
; CHECK: 3:
; CHECK-NEXT: ret i32 -1
;
br i1 %0, label %2, label %3

2: ; preds = %1
Expand All @@ -65,24 +87,40 @@ declare void @__cxa_rethrow()
; return 1;
; }

; CHECK: define i32 @catch_thing()
define i32 @catch_thing() personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: define {{[^@]+}}@catch_thing() personality ptr @__gxx_personality_v0 {
; CHECK-NEXT: invoke void @__cxa_rethrow()
; CHECK-NEXT: to label [[TMP1:%.*]] unwind label [[TMP2:%.*]]
; CHECK: 1:
; CHECK-NEXT: unreachable
; CHECK: 2:
; CHECK-NEXT: [[TMP3:%.*]] = landingpad { ptr, i32 }
; CHECK-NEXT: catch ptr null
; CHECK-NEXT: [[TMP4:%.*]] = extractvalue { ptr, i32 } [[TMP3]], 0
; CHECK-NEXT: [[TMP5:%.*]] = tail call ptr @__cxa_begin_catch(ptr [[TMP4]])
; CHECK-NEXT: tail call void @__cxa_end_catch()
; CHECK-NEXT: ret i32 -1
;
invoke void @__cxa_rethrow() #1
to label %1 unwind label %2
to label %1 unwind label %2

1: ; preds = %0
unreachable

2: ; preds = %0
%3 = landingpad { ptr, i32 }
catch ptr null
catch ptr null
%4 = extractvalue { ptr, i32 } %3, 0
%5 = tail call ptr @__cxa_begin_catch(ptr %4) #2
tail call void @__cxa_end_catch()
ret i32 -1
}

define i32 @catch_thing_user() {
; CHECK-LABEL: define {{[^@]+}}@catch_thing_user() {
; CHECK-NEXT: [[CATCH_THING_CALL:%.*]] = call i32 @catch_thing()
; CHECK-NEXT: ret i32 [[CATCH_THING_CALL]]
;
%catch_thing_call = call i32 @catch_thing()
ret i32 %catch_thing_call
}
Expand Down
27 changes: 17 additions & 10 deletions llvm/test/Transforms/FunctionAttrs/operand-bundles-scc.ll
@@ -1,17 +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

define void @f() {
; CHECK-LABEL: define void @f() #0 {
call void @g() [ "unknown"() ]
ret void
; CHECK: Function Attrs: nofree nosync nounwind
; CHECK-LABEL: define {{[^@]+}}@f
; CHECK-SAME: () #[[ATTR0:[0-9]+]] {
; CHECK-NEXT: call void @g() [ "unknown"() ]
; CHECK-NEXT: ret void
;
call void @g() [ "unknown"() ]
ret void
}

define void @g() {
; CHECK-LABEL: define void @g() #0 {
call void @f()
ret void
; CHECK: Function Attrs: nofree nosync nounwind
; CHECK-LABEL: define {{[^@]+}}@g
; CHECK-SAME: () #[[ATTR0]] {
; CHECK-NEXT: call void @f()
; CHECK-NEXT: ret void
;
call void @f()
ret void
}


; CHECK: attributes #0 = { nofree nosync nounwind }
20 changes: 15 additions & 5 deletions llvm/test/Transforms/FunctionAttrs/read-write-scc.ll
@@ -1,20 +1,30 @@
; 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

@i = global i32 0

define void @foo() {
; CHECK-LABEL: define void @foo() #0 {
; CHECK: Function Attrs: nofree nosync nounwind
; CHECK-LABEL: define {{[^@]+}}@foo
; CHECK-SAME: () #[[ATTR0:[0-9]+]] {
; CHECK-NEXT: store i32 1, ptr @i, align 4
; CHECK-NEXT: call void @bar()
; CHECK-NEXT: ret void
;
store i32 1, ptr @i
call void @bar()
ret void
}

define void @bar() {
; CHECK-LABEL: define void @bar() #0 {
; CHECK: Function Attrs: nofree nosync nounwind
; CHECK-LABEL: define {{[^@]+}}@bar
; CHECK-SAME: () #[[ATTR0]] {
; CHECK-NEXT: [[I:%.*]] = load i32, ptr @i, align 4
; CHECK-NEXT: call void @foo()
; CHECK-NEXT: ret void
;
%i = load i32, ptr @i
call void @foo()
ret void
}

; CHECK: attributes #0 = { nofree nosync nounwind }

0 comments on commit 86126db

Please sign in to comment.