[Sink][test] Add nounwind test and properly test convergent

This commit is contained in:
Fangrui Song 2020-08-30 18:26:15 -07:00
parent 3f6f7f6b7b
commit e148cbff94
2 changed files with 15 additions and 2 deletions

View File

@ -1,6 +1,7 @@
; RUN: opt < %s -basic-aa -sink -S | FileCheck %s
declare i32 @f_load_global() nounwind readonly
declare i32 @f_load_global_throwable() readonly
declare i32 @f_load_arg(i32*) nounwind readonly argmemonly
declare void @f_store_global(i32) nounwind
declare void @f_store_arg(i32*) nounwind argmemonly
@ -25,6 +26,18 @@ false:
ret i32 0
}
; CHECK-LABEL: @test_throwable_no_stores(
; CHECK: %l = call i32 @f_load_global
; CHECK-NEXT: br i1 %z
define i32 @test_throwable_no_stores(i1 %z) {
%l = call i32 @f_load_global_throwable()
br i1 %z, label %true, label %false
true:
ret i32 %l
false:
ret i32 0
}
; CHECK-LABEL: @test_sink_argmem_store(
; CHECK: true:
; CHECK-NEXT: %l = call i32 @f_load_arg

View File

@ -10,7 +10,7 @@
define i32 @foo(i1 %arg) {
entry:
%c = call i32 @bar() readonly convergent
%c = call i32 @bar() nounwind readonly convergent
br i1 %arg, label %then, label %end
then:
@ -20,4 +20,4 @@ end:
ret i32 0
}
declare i32 @bar() readonly convergent
declare i32 @bar() nounwind readonly convergent