<div dir="ltr">Agreed - if we're going to provide any debug info for this (line table, etc) it's necessarily going to be confusing (in the case where we've outlined from more than one place) but I think it's the right-est thing to do, that I can think of right now, given the constraints, and we should just follow through with it as far as possible in that direction (so, a function with the same filename, same line entries, etc, from that one instance we picked)<br><br>In theory, inline functions have the same issue, sort of - in one translation unit you call inline function f1 which you may've written in foo.cpp, and then in another translation unit you have another inline definition of f1 in bar.cpp - so long as both definitions have the same sequence/interpretation of tokens, you haven't violated the ODR, but in theory the user might be confused by the fact that their code in foo.cpp that clearly called f1 in foo.cpp actually jumps over to f1 in bar.cpp. (yeah, admittedly that's not nearly as confusing as outlining - but that's the nearest analogy I have & best idea I have for modelling this: as though the user did the outlining and the linker picked a definition (except we can be smart and intentionally pick a definition that has debug info, if there is one))<br><br><div class="gmail_quote"><div dir="ltr">On Thu, Jan 18, 2018 at 3:44 PM Paul Robinson 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">probinson added inline comments.<br>
<br>
<br>
================<br>
Comment at: lib/CodeGen/MachineOutliner.cpp:1283<br>
+    std::unique_ptr<DIBuilder> DB = llvm::make_unique<DIBuilder>(M, true, CU);<br>
+    DIFile *Unit = DB->createFile(CU->getName(), CU->getDirectory());<br>
+<br>
----------------<br>
aprantl wrote:<br>
> paquette wrote:<br>
> > aprantl wrote:<br>
> > > aprantl wrote:<br>
> > > > Can you also grab the file from the DISubprogram that you got the CU from?<br>
> > > Looks like this one was accidentally marked as done?<br>
> > It's CU->getFile() on here now but in the e-mail thread, it appears to still be<br>
> ><br>
> > DIFile *Unit = DB->createFile(CU->getName(), CU->getDirectory())<br>
> ><br>
> > Maybe that got mixed up somehow? Or is that still incorrect? Is it possible for a DISubprogram to have a different DIFile than its CU?<br>
> > Is it possible for a DISubprogram to have a different DIFile than its CU?<br>
> Yes. For example, two functions defined in different header files have different files even if they belong to the same CU.<br>
><br>
> My original suggestion was to use SP->getFile() here where SP is the DISubprogram attached to the function we got the CU from.<br>
><br>
> That said, if we are outlining code from two function from two different files, this file will be wrong and I'm not sure how to handle this. Should we create a new "virtual" file "<outlined-code>"? What do others think?<br>
I think taking the DIFile from the same DISubprogram where we got the CU is fine.  It's more consistent than anything else we could do.<br>
<br>
<br>
<a href="https://reviews.llvm.org/D42254" rel="noreferrer" target="_blank">https://reviews.llvm.org/D42254</a><br>
<br>
<br>
<br>
</blockquote></div></div>