[llvm] 8600d89 - [DSE] Add test for interaction with return-only captures (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 13 06:23:02 PST 2025
Author: Nikita Popov
Date: 2025-02-13T15:19:05+01:00
New Revision: 8600d89e55b866186a2dad2e2b4c85bd96150375
URL: https://github.com/llvm/llvm-project/commit/8600d89e55b866186a2dad2e2b4c85bd96150375
DIFF: https://github.com/llvm/llvm-project/commit/8600d89e55b866186a2dad2e2b4c85bd96150375.diff
LOG: [DSE] Add test for interaction with return-only captures (NFC)
Regression test for the miscompile reported at:
https://github.com/llvm/llvm-project/pull/125880#issuecomment-2656632577
Added:
llvm/test/Transforms/DeadStoreElimination/captures-ret-only.ll
Modified:
Removed:
################################################################################
diff --git a/llvm/test/Transforms/DeadStoreElimination/captures-ret-only.ll b/llvm/test/Transforms/DeadStoreElimination/captures-ret-only.ll
new file mode 100644
index 0000000000000..962b08513a6a0
--- /dev/null
+++ b/llvm/test/Transforms/DeadStoreElimination/captures-ret-only.ll
@@ -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
+}
More information about the llvm-commits
mailing list