[PATCH] D42254: Add optional DICompileUnit to DIBuilder and make outlined debug info use that CU

Paul Robinson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 18 15:44:27 PST 2018


probinson added inline comments.


================
Comment at: lib/CodeGen/MachineOutliner.cpp:1283
+    std::unique_ptr<DIBuilder> DB = llvm::make_unique<DIBuilder>(M, true, CU);
+    DIFile *Unit = DB->createFile(CU->getName(), CU->getDirectory());
+
----------------
aprantl wrote:
> paquette wrote:
> > aprantl wrote:
> > > aprantl wrote:
> > > > Can you also grab the file from the DISubprogram that you got the CU from?
> > > Looks like this one was accidentally marked as done?
> > It's CU->getFile() on here now but in the e-mail thread, it appears to still be 
> > 
> > DIFile *Unit = DB->createFile(CU->getName(), CU->getDirectory())
> > 
> > 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?
> > Is it possible for a DISubprogram to have a different DIFile than its CU?
> Yes. For example, two functions defined in different header files have different files even if they belong to the same CU.
> 
> My original suggestion was to use SP->getFile() here where SP is the DISubprogram attached to the function we got the CU from.
> 
> 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?
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.


https://reviews.llvm.org/D42254





More information about the llvm-commits mailing list