Before this change, personality directives were not emitted if there was no landing pad left in the function
(of course until recently this also meant that we couldn't know what the personality actually was).
Allow this now and add a test case for it.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
lib/CodeGen/AsmPrinter/DwarfCFIException.cpp | ||
---|---|---|
95 ↗ | (On Diff #28903) | should we require that it's not nounwind? |
lib/CodeGen/AsmPrinter/DwarfCFIException.cpp | ||
---|---|---|
95 ↗ | (On Diff #28903) | Right, yes, we discussed that on IRC. |
This seems like it's going to produce a lot of useless personality data in C++. I'd be OK with this if our mid-level optimizers were more aggressive about removing known Itanium personalities from functions with no landingpads.
Updated based on discussion with to use EHPersonality @rnk to still omit known personality function if they are known to be noops.
include/llvm/Analysis/LibCallSemantics.h | ||
---|---|---|
209–211 ↗ | (On Diff #29600) | We're about to add new blocks that invokes can unwind to, so perhaps let's flip this around and talk about invokes. Maybe isNoOpWithoutInvoke? |
lib/CodeGen/AsmPrinter/DwarfCFIException.cpp | ||
119 ↗ | (On Diff #29600) | For historical reasons, we often have bitcasts around personality functions. You should do getPersonalityFn()->stripPointerCasts(). |
121–122 ↗ | (On Diff #29600) | Now that the personality is on the IR function, this should never return anything other than the value computed above. After fixing the casting issue, can we change this to an assertion? |
Oh, you should also update WinException.cpp and ARMException.cpp to have this behavior.
Addresses @rnk's review comments:
isNoOpWithoutLpads -> isNoOpWithoutInvoke and add the same logic to Win and ARM
lgtm
lib/CodeGen/AsmPrinter/DwarfCFIException.cpp | ||
---|---|---|
110–111 ↗ | (On Diff #29614) | I was trying to get away from relying on MMI->getPersonality() at all. Something like: const Function *Per = nullptr; if (F->hasPersonalityFn()) Per = dyn_cast<Function>(F->getPersonalityFn()->stripPointerCasts()); assert(Per == MMI->getPersonality()); Eventually we probably want to rip out MMI's tracking of EH personalities, now that they aren't on landingpads. For now, though, we should ensure that MMI is in sync with the IR. |
Unfortunately it looks like the assertion does not hold true on ARM. Shall I just go back to using either or shall I figure out why the assertions doesn't hold?
Actually, the difference seems to be running the tests on my local Mac vs my (Linux) development machine. Will investigate.
Actually, duh. It's precisely not true in the case where there is no landing pads remaining, which is the whole point of this change - I should go home!
Updated to only check for matching personalities if there is one recorded in the MMI. @rnk does that sound ok?