[llvm] [IR] Avoid redundant IRBuilder debug loc updates (PR #193018)

Alexis Engelke via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 21 04:15:15 PDT 2026


aengelke wrote:

> This actually is already implemented there

Is it really? This just checks the address of the TrackingMDRef, not whether the MD itself is equal. I think we could add a check for MD == X.MD there.

https://github.com/llvm/llvm-project/blob/cf1f7c53342594a6a004fc7d75e41a9ff009883c/llvm/include/llvm/IR/TrackingMDRef.h#L35-L37

Copying DebugLoc/TrackingMDRef is likely not more expensive than moving: metadata tracking uses the address of the MDNode*, so moving a DebugLoc also needs to call untrack/track.

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


More information about the llvm-commits mailing list