llvm-project/llvm/test/Transforms/Inline/implicit-null-check.ll
Denis Antrushin 291223409c [InlineCost] Consider branches with !make.implicit metadata as free.
!make.implicit metadata attached to branch means it will very likely
be eliminated (together with associated cmp instruction).

Reviewed By: apilipenko

Differential Revision: https://reviews.llvm.org/D149747
2023-05-25 18:43:16 +03:00

25 lines
457 B
LLVM

; RUN: opt -passes=inline -inline-threshold=10 -S < %s | FileCheck %s
declare void @foo()
; CHECK-LABEL: @caller
; CHECK-NOT: %res = call i64 @callee(ptr %p)
define i64 @caller(ptr %p) {
%res = call i64 @callee(ptr %p)
ret i64 %res
}
define i64 @callee(ptr %p) {
%null_check = icmp eq ptr %p, null
br i1 %null_check, label %is_null, label %non_null, !make.implicit !0
is_null:
call void @foo()
ret i64 0
non_null:
ret i64 1
}
!0 = !{}