Files
clang-p2996/llvm/test/Transforms/FunctionAttrs/incompatible_fn_attrs.ll
Nikita Popov 65fd034b95 [FunctionAttrs] Infer willreturn for functions without loops
If a function doesn't contain loops and does not call non-willreturn
functions, then it is willreturn. Loops are detected by checking
for backedges in the function. We don't attempt to handle finite
loops at this point.

Differential Revision: https://reviews.llvm.org/D94633
2021-01-21 20:29:33 +01:00

33 lines
1.1 KiB
LLVM

; RUN: opt -S -o - -function-attrs %s | FileCheck %s
; 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 i32* @given_argmem_infer_readnone(i32* %p) #0 {
; CHECK: define i32* @given_argmem_infer_readnone(i32* readnone returned %p) #0 {
entry:
ret i32* %p
}
; Function Attrs: inaccessiblememonly
define i32* @given_inaccessible_infer_readnone(i32* %p) #1 {
; CHECK: define i32* @given_inaccessible_infer_readnone(i32* readnone returned %p) #0 {
entry:
ret i32* %p
}
; Function Attrs: inaccessiblemem_or_argmemonly
define i32* @given_inaccessible_or_argmem_infer_readnone(i32* %p) #2 {
; CHECK: define i32* @given_inaccessible_or_argmem_infer_readnone(i32* readnone returned %p) #0 {
entry:
ret i32* %p
}
attributes #0 = { argmemonly }
attributes #1 = { inaccessiblememonly }
attributes #2 = { inaccessiblemem_or_argmemonly }
; CHECK: attributes #0 = { norecurse nounwind readnone willreturn }
; CHECK-NOT: attributes