<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Mon, May 8, 2017 at 1:45 PM Adrian Prantl via Phabricator <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">aprantl marked 3 inline comments as done.<br>
aprantl added inline comments.<br>
<br>
<br>
================<br>
Comment at: lib/Transforms/Utils/CloneFunction.cpp:131<br>
+        (MD.first == LLVMContext::MD_dbg && OldFunc->getParent() &&<br>
+         OldFunc->getParent() == NewFunc->getParent());<br>
+    if (MustCloneSP) {<br>
----------------<br>
dblaikie wrote:<br>
> Is this ever not true? I guess it could be if CloneFunction is used to clone from one Module to another? is that a thing that happens?<br>
This is public LLVM API, so I think we need to brace for every possibility here.<br></blockquote><div><br>Not sure what you mean by "public" API - and in any case, if there's no use currently in-tree, I think an assert would be more appropriate. Then once there's a clear use case it can be supported, tested, etc?<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
================<br>
Comment at: unittests/Transforms/Utils/Cloning.cpp:391-392<br>
       // But that they belong to different functions<br>
-      auto *OldSubprogram = cast<DISubprogram>(OldDL.getScope());<br>
-      auto *NewSubprogram = cast<DISubprogram>(NewDL.getScope());<br>
+      auto *OldSubprogram = cast<DISubprogram>(OldDL.getInlinedAtScope());<br>
+      auto *NewSubprogram = cast<DISubprogram>(NewDL.getInlinedAtScope());<br>
       EXPECT_EQ(OldFunc->getSubprogram(), OldSubprogram);<br>
----------------<br>
dblaikie wrote:<br>
> I don't really understand why this change is here - could you explain it?<br>
><br>
> I guess the actual change you made to CloneFunction makes the new function look as though the old function was inlined into it? That's a great idea/way to do it! :) (though won't be what I need for the LTO+Fission issue - but perhaps I can use some of the pieces you've built/generalized/etc here)<br>
Much simpler: This change is necessary because above, I'm adding an inlined function into OldFunc (line 309ff). DILocation::getInlinedAtScope() returns either the parent function of a regular instruction or the parent of the inlined-at location of an inlined instruction, both of which should be the DISubprogram attached to the function the instruction is part of.<br>
<br>
<br>
<a href="https://reviews.llvm.org/D32975" rel="noreferrer" target="_blank">https://reviews.llvm.org/D32975</a><br>
<br>
<br>
<br>
</blockquote></div></div>