[llvm] [DebugInfo][RemoveDIs] Instrument loop-rotate for DPValues (PR #72997)

Jeremy Morse via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 22 07:42:07 PST 2023


================
@@ -539,6 +575,20 @@ bool LoopRotate::rotateLoop(Loop *L, bool SimplifiedLatch) {
       if (auto *Decl = dyn_cast<NoAliasScopeDeclInst>(&I))
         NoAliasDeclInstructions.push_back(Decl);
 
+    Module *M = OrigHeader->getModule();
+
+    // Track the next DPValue to clone. If we have a sequence where an
+    // instruction is hoisted instead of being cloned:
+    //    DPValue blah
+    //    %foo = add i32 0, 0
+    //    DPValue xyzzy
+    //    %bar = call i32 @foobar()
+    // where %foo is hoisted, then the DPValue "blah" will be seen twice, once
+    // attached to %foo, then to %bar as it will "fall down" onto the call.
+    // cloneDebugInfoFrom takes an optional "start cloning from here" position
+    // to account for this behaviour.
----------------
jmorse wrote:

I've added more illustration in the example, pls2review. I'll refrain from explaining it here so that it's all in the comment.

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


More information about the llvm-commits mailing list