[PATCH] D42254: Add optional DICompileUnit to DIBuilder and make outlined debug info use that CU
Justin Bogner via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 18 12:34:46 PST 2018
Jessica Paquette via Phabricator via llvm-commits
<llvm-commits at lists.llvm.org> writes:
> paquette created this revision.
> paquette added reviewers: aprantl, probinson, dblaikie.
> Herald added a subscriber: JDevlieghere.
>
> Previously, I committed a change to the outliner which added some
> debug information to outlined functions. This wasn't entirely great
> because DIBuilder only sets its CU using createCompileUnit. As a
> result, the outliner had to make a second compile unit just for the
> outlined sequences.
>
> This sparked an e-mail discussion on the topic, so I'm putting the
> patch up here just because it's a bit easier to read + discuss.
>
> The only change to DIBuilder is an added optional parameter in the
> constructor which allows you to set the CU if you already know what
> you want. There are no functional changes to it otherwise. The rest of
> the changes are in the outliner. It works like this:
>
> 1. Keep track of the MachineFunction that each Candidate appears
> in. Use that to get a CU for that Candidate if possible.
> 2. To find a CU for an OutlinedFunction, grab the first CU belonging
> to some Candidate associated with that function.
> 3. When you create a function, see if it has a potential CU. If it
> does, then generate debug info for the outlined function.
Drive by style nit:
> + /// \brief If there is a DICompileUnit for any Candidate for this outlined
> + /// function, then return it. Otherwise, return nullptr.
> + DICompileUnit *getCUIfExists() const {
> + DICompileUnit *CU = nullptr;
> + for (auto &C : Candidates) {
> + CU = C->getCUIfExists();
> + if (CU)
> + break;
> + }
> + return CU;
> + }
DICompileUnit *getCUIfExists() const {
for (auto &C : Candidates)
if (DICompileUnit *CU = C->getCUIfExists())
return CU;
return nullptr;
}
More information about the llvm-commits
mailing list