This is an archive of the discontinued LLVM Phabricator instance.

SelectionDAGBuilder, mach-o: Skip trap after noreturn call (for Mach-O)
ClosedPublic

Authored by MatzeB on Jun 27 2018, 2:26 PM.

Details

Summary

Add NoTrapAfterNoreturn target option which skips emission of traps
behind noreturn calls even if TrapUnreachable is enabled.

rdar://41530228

Diff Detail

Repository
rL LLVM

Event Timeline

MatzeB created this revision.Jun 27 2018, 2:26 PM
t.p.northover accepted this revision.Jun 28 2018, 1:39 AM

This looks reasonable to me.

This revision is now accepted and ready to land.Jun 28 2018, 1:39 AM

Out of curiosity, what's the use case/motivation for this?

Out of curiosity, what's the use case/motivation for this?

It reduces code size (0.5-1.2%) in the projects I measured.

This feature was/is only enabled in -O0, though, right? As a debugging aid,
if I recall correctly - because it can be super confusing when your code
falls off the end of one function into the next. Is the code size savings
(only at O0) worth the increased cost to debug?

rnk added a comment.Aug 27 2019, 3:14 PM

These two MachO specific configurations seem like needlessly MachO specific policy decisions. I think it would make more sense for the project overall if we emitted traps for unreachables not preceded by noreturn calls for all targets. As you've noticed, the vast majority of unreachables are from calls to noreturn functions. The remainder account for the confusing and hard to debug fall through cases. I believe noreturn functions rarely return erroneously, and are usually not problematic for the user.

Herald added a project: Restricted Project. · View Herald TranscriptAug 27 2019, 3:14 PM
rnk added a comment.Aug 27 2019, 4:00 PM

By the way, once upon a time I *almost* removed TrapOnUnreachable in rL248959, but I had to revert it for reasons I am trying to rediscover.