[llvm] [DSE] Stop double-counting the dead slice offset in shortenAssignment (PR #216227)

Eric Christopher via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 16 23:23:27 PDT 2026


================
@@ -0,0 +1,90 @@
+; RUN: opt %s -S -passes=dse -o - | FileCheck %s --implicit-check-not="#dbg_"
+
+;; The IR is clang's, with only the cleanup listed below. The variable fills its
+;; alloca, so the source byte offsets can be checked directly against the test.
+;;
+;; $ cat shorten.c
+;; void esc(char *);
+;; void shortenBeginPartial(void) {
+;;   char local[80];
+;;   __builtin_memset(local + 8, 0, 72);
+;;   __builtin_memset(local + 4, 8, 64);
+;;   esc(local);
+;; }
+;;
+;; $ clang -O2 -g -gno-key-instructions -c \
+;;       -Xclang -fexperimental-assignment-tracking=forced \
+;;       -mllvm -print-before=dse -mllvm -print-module-scope shorten.c \
+;;       -o /dev/null
+;;
+;; and then, by hand: dropped the target triple and datalayout so this runs
+;; anywhere, dropped the tbaa metadata, llvm.ident, the producer/checksum/
+;; sysroot strings, the lifetime intrinsics and the function attributes, and
+;; renumbered the metadata. The remaining non-debug instructions keep clang's
+;; order and operands, and the assignment offsets are unchanged.
+
+;; 'local' is 640 bits and starts at the alloca, so variable bit N is alloca
+;; byte N/8 throughout, which is what makes the arithmetic readable.
----------------
echristo wrote:

No worries at all. It's a good point and I should have as well. 

https://github.com/llvm/llvm-project/pull/216227


More information about the llvm-commits mailing list