llvm-project/llvm/test/Transforms/InstCombine/skip-opt-void-to-non-void-conversion.ll
YongKang Zhu 6c367168d6
[InstCombine] Remove transformation on call instruction where return value need void to non-void conversion (#98536)
Skip simplification on call instruction where a non-void return value is
expected but the callee returns void, which is undefined behavior and
could lead to non-determinism or crashes.
2024-08-02 09:07:48 -07:00

34 lines
704 B
LLVM

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
; RUN: opt --passes=instcombine -S < %s | FileCheck %s
define void @foo() {
; CHECK-LABEL: define void @foo() {
; CHECK-NEXT: [[ENTRY:.*:]]
; CHECK-NEXT: ret void
;
entry:
ret void
}
define i32 @bar() {
; CHECK-LABEL: define i32 @bar() {
; CHECK-NEXT: [[ENTRY:.*:]]
; CHECK-NEXT: [[TMP0:%.*]] = tail call i32 @foo()
; CHECK-NEXT: ret i32 [[TMP0]]
;
entry:
%1 = tail call i32 @foo()
ret i32 %1
}
define void @goo() {
; CHECK-LABEL: define void @goo() {
; CHECK-NEXT: [[ENTRY:.*:]]
; CHECK-NEXT: call void @foo()
; CHECK-NEXT: ret void
;
entry:
%res = call i32 @foo()
ret void
}