forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[InstCombine] Remove transformation on call instruction where return …
…value need void to non-void conversion (llvm#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.
- Loading branch information
1 parent
678159f
commit 3ba7ebd
Showing
2 changed files
with
42 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
llvm/test/Transforms/InstCombine/skip-opt-void-to-non-void-conversion.ll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
; 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 | ||
} |