[llvm] [DAGCombiner] Preserve debug location of original load in fold (conv (load x)) (PR #160236)

via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 23 01:03:13 PDT 2025


================
@@ -16703,7 +16703,7 @@ SDValue DAGCombiner::visitBITCAST(SDNode *N) {
         }
       }
       SDValue Load =
-          DAG.getLoad(VT, SDLoc(N), LN0->getChain(), LN0->getBasePtr(),
+          DAG.getLoad(VT, SDLoc(LN0), LN0->getChain(), LN0->getBasePtr(),
----------------
jwu10003 wrote:

> Would getMergedLocation work better?

I did some experiments:
**LN0** loc = test.py:8:16
**N** loc = test.py:9:20
=>
**getMergedLocation(LN0, N)** = test.py:0

Is this as expected?  

The code is as follows. If there are any mistakes, please point them out to me.
<img width="859" height="192" alt="image" src="https://github.com/user-attachments/assets/0c474b9d-b1bc-4f40-af95-9729743b3f5a" />


However, the test needs to check **test.py:8:16**.

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


More information about the llvm-commits mailing list