[llvm] dbc2f65 - [IPSCCP] Add tests for noundef attribute on zapped returns (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 21 01:54:09 PST 2023
Author: Nikita Popov
Date: 2023-02-21T10:54:00+01:00
New Revision: dbc2f65ad50c12cf986e2140295ab7b4318d8f39
URL: https://github.com/llvm/llvm-project/commit/dbc2f65ad50c12cf986e2140295ab7b4318d8f39
DIFF: https://github.com/llvm/llvm-project/commit/dbc2f65ad50c12cf986e2140295ab7b4318d8f39.diff
LOG: [IPSCCP] Add tests for noundef attribute on zapped returns (NFC)
We replace the return value with undef without dropping the
noundef attribute.
Added:
llvm/test/Transforms/SCCP/ipsccp-noundef.ll
Modified:
Removed:
################################################################################
diff --git a/llvm/test/Transforms/SCCP/ipsccp-noundef.ll b/llvm/test/Transforms/SCCP/ipsccp-noundef.ll
new file mode 100644
index 0000000000000..e799f1e02c254
--- /dev/null
+++ b/llvm/test/Transforms/SCCP/ipsccp-noundef.ll
@@ -0,0 +1,54 @@
+; RUN: opt -S -passes=ipsccp < %s | FileCheck %s
+ at g = external global i8
+
+define internal noundef i32 @ret_noundef() {
+; CHECK-LABEL: define internal noundef i32 @ret_noundef() {
+; CHECK-NEXT: ret i32 undef
+;
+ ret i32 0
+}
+
+define internal dereferenceable(1) ptr @ret_dereferenceable() {
+; CHECK-LABEL: define internal dereferenceable(1) ptr @ret_dereferenceable() {
+; CHECK-NEXT: ret ptr undef
+;
+ ret ptr @g
+}
+
+define internal dereferenceable_or_null(1) ptr @ret_dereferenceable_or_null() {
+; CHECK-LABEL: define internal dereferenceable_or_null(1) ptr @ret_dereferenceable_or_null() {
+; CHECK-NEXT: ret ptr undef
+;
+ ret ptr @g
+}
+
+define internal nonnull ptr @ret_nonnull() {
+; CHECK-LABEL: define internal nonnull ptr @ret_nonnull() {
+; CHECK-NEXT: ret ptr undef
+;
+ ret ptr @g
+}
+
+define internal nonnull noundef ptr @ret_nonnull_noundef() {
+; CHECK-LABEL: define internal noundef nonnull ptr @ret_nonnull_noundef() {
+; CHECK-NEXT: ret ptr undef
+;
+ ret ptr @g
+}
+
+define void @test() {
+; CHECK-LABEL: define void @test() {
+; CHECK-NEXT: [[TMP1:%.*]] = call noundef i32 @ret_noundef()
+; CHECK-NEXT: [[TMP2:%.*]] = call dereferenceable(1) ptr @ret_dereferenceable()
+; CHECK-NEXT: [[TMP3:%.*]] = call dereferenceable_or_null(1) ptr @ret_dereferenceable_or_null()
+; CHECK-NEXT: [[TMP4:%.*]] = call nonnull ptr @ret_nonnull()
+; CHECK-NEXT: [[TMP5:%.*]] = call noundef nonnull ptr @ret_nonnull_noundef()
+; CHECK-NEXT: ret void
+;
+ call noundef i32 @ret_noundef()
+ call dereferenceable(1) ptr @ret_dereferenceable()
+ call dereferenceable_or_null(1) ptr @ret_dereferenceable_or_null()
+ call nonnull ptr @ret_nonnull()
+ call nonnull noundef ptr @ret_nonnull_noundef()
+ ret void
+}
More information about the llvm-commits
mailing list