Skip to content

Commit

Permalink
[IPSCCP] Add tests for noundef attribute on zapped returns (NFC)
Browse files Browse the repository at this point in the history
We replace the return value with undef without dropping the
noundef attribute.
  • Loading branch information
nikic committed Feb 21, 2023
1 parent b486246 commit dbc2f65
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions llvm/test/Transforms/SCCP/ipsccp-noundef.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
; RUN: opt -S -passes=ipsccp < %s | FileCheck %s
@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
}

0 comments on commit dbc2f65

Please sign in to comment.