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:
- Keep track of the MachineFunction that each Candidate appears in. Use that to get a CU for that Candidate if possible.
- To find a CU for an OutlinedFunction, grab the first CU belonging to some Candidate associated with that function.
- When you create a function, see if it has a potential CU. If it does, then generate debug info for the outlined function.
How about getCompileUnitOrNull?