[llvm] Add debug location to strlen in LoopIdiomRecognize pass (PR #140164)

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Thu May 15 16:55:35 PDT 2025


================
@@ -1778,6 +1778,9 @@ bool LoopIdiomRecognize::recognizeAndInsertStrLen() {
   }
   assert(StrLenFunc && "Failed to emit strlen function.");
 
+  // Set debug location to the start of the loop.
+  cast<Instruction>(StrLenFunc)->setDebugLoc(CurLoop->getStartLoc());
----------------
dwblaikie wrote:

Could the static type of `StrLenFunc` be updated to `Instruction*` so the cast isn't needed here?

Or, alternatively,  perhaps it'd be better to set the debug location on the irbuilder, which will then be used for the instructions?

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


More information about the llvm-commits mailing list