Issue 138647
Summary [DebugInfo] RAUW updates debug value addresses using undefined local variables
Labels question, debuginfo
Assignees
Reporter Apochens
    When inspecting debug value updates in MemCpyOptimizer, I encountered a case: https://godbolt.org/z/WW98j8dPf. In short, I found a testcase that leads to a `dbg_value` referring to an undefined local variable after applying MemCpyOptimizer:

```llvm
    #dbg_value(ptr %test_array_b, !9, !DIExpression(), !16) ; refers to a local variable defined after it
 %test_array_b = alloca [31 x float], align 4, !dbg !17
    #dbg_value(ptr %test_array_b, !11, !DIExpression(), !17)
```

The code in MemCpyOptimizer leading to the IR is given in below:

https://github.com/llvm/llvm-project/blob/716b02d8c575afde7af1af13df145019659abca2/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp#L1668-L1669

And the code root for updating the metadata (i.e., `dbg_value`) is:

https://github.com/llvm/llvm-project/blob/41b76119ecc2b22546dc27ca51947304cf5aca28/llvm/lib/IR/Metadata.cpp#L588-L594

Is this an expected behavior? cc @OCHyams 
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to