Skip to content

Commit

Permalink
[DSE] Add test for interaction with return-only captures (NFC)
Browse files Browse the repository at this point in the history
Regression test for the miscompile reported at:
llvm/llvm-project#125880 (comment)
  • Loading branch information
nikic committed Feb 13, 2025
1 parent a33a84e commit 8600d89
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions llvm/test/Transforms/DeadStoreElimination/captures-ret-only.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
; RUN: opt -S -passes=dse < %s | FileCheck %s

declare ptr @passthrough(ptr)

define i16 @ret_only() {
; CHECK-LABEL: define i16 @ret_only() {
; CHECK-NEXT: [[A:%.*]] = alloca i16, align 1
; CHECK-NEXT: store i16 1, ptr [[A]], align 1
; CHECK-NEXT: [[CALL:%.*]] = call ptr @passthrough(ptr readnone captures(ret: address, provenance) [[A]])
; CHECK-NEXT: [[V:%.*]] = load i16, ptr [[CALL]], align 1
; CHECK-NEXT: ret i16 [[V]]
;
%a = alloca i16, align 1
store i16 1, ptr %a, align 1
%call = call ptr @passthrough(ptr readnone captures(ret: address, provenance) %a)
%v = load i16, ptr %call, align 1
ret i16 %v
}

define i16 @ret_has_more_components() {
; CHECK-LABEL: define i16 @ret_has_more_components() {
; CHECK-NEXT: [[A:%.*]] = alloca i16, align 1
; CHECK-NEXT: store i16 1, ptr [[A]], align 1
; CHECK-NEXT: [[CALL:%.*]] = call ptr @passthrough(ptr readnone captures(address, ret: address, provenance) [[A]])
; CHECK-NEXT: [[V:%.*]] = load i16, ptr [[CALL]], align 1
; CHECK-NEXT: ret i16 [[V]]
;
%a = alloca i16, align 1
store i16 1, ptr %a, align 1
%call = call ptr @passthrough(ptr readnone captures(address, ret: address, provenance) %a)
%v = load i16, ptr %call, align 1
ret i16 %v
}

0 comments on commit 8600d89

Please sign in to comment.