[llvm] [SimplifyCFG] correct and move debug info for mergeConditionalStoreToAddress (PR #180789)
Jameson Nash via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 11 07:06:50 PST 2026
================
@@ -0,0 +1,78 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -passes=simplifycfg < %s -S | FileCheck %s
+
+; Test that SimplifyCFG properly preserves debug info when merging conditional stores.
+; This test verifies that:
+; 1. DIAssignID metadata is properly merged.
+; 2. The hoisted dbg_assign value correctly represents the merged store value.
+
+define void @merge_stores_different_values(ptr %p, i32 %a, i32 %b) !dbg !10 {
+; CHECK-LABEL: @merge_stores_different_values(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[X1:%.*]] = icmp eq i32 [[A:%.*]], 0, !dbg [[DBG15:![0-9]+]]
+; CHECK-NEXT: [[X2:%.*]] = icmp eq i32 [[B:%.*]], 0, !dbg [[DBG16:![0-9]+]]
+; CHECK-NEXT: #dbg_assign(i32 [[SPEC_SELECT:%.*]], [[META17:![0-9]+]], !DIExpression(), [[META18:![0-9]+]], ptr [[P:%.*]], !DIExpression(), [[META19:![0-9]+]])
----------------
vtjnash wrote:
I was somewhat curious about that–surely there's already other sinking passes that would break SSA of this metadata argument too? If we're going for generally avoiding moving them, and for not including them in DOM-tree use analysis, should it be the job of isel to legalize that?
> that is pretty darn close to proving that we haven't moved these assignments across other assignments,
I was also 99% sure of that, but couldn't convince myself of the last 1%. Could there somehow be other dbg_assign statements here that we'd be moving it past? The documentation is imprecise when it comes to explain what it means when the value and address information will contradict each other, as they will in between the original dbg_assign location and the final location where the store gets moved to (which may move past other, non-aliasing function calls and such) at https://llvm.org/docs/AssignmentTracking.html#lowering-dbg-assign-to-mir
https://github.com/llvm/llvm-project/pull/180789
More information about the llvm-commits
mailing list