This is an archive of the discontinued LLVM Phabricator instance.

Adjust `llvm_unreachable` macro to account for platforms that don't define LLVM_BUILTIN_UNREACHABLE
ClosedPublic

Authored by mehdi_amini on Mar 21 2022, 1:00 PM.

Details

Summary

Post 892c104fb7, LLVM_BUILTIN_UNREACHABLE may not be defined anymore.
Also when LLVM_UNREACHABLE_OPTIMIZE is OFF, emit LLVM_BUILTIN_UNREACHABLE
after LLVM_BUILTIN_TRAP to ensure that diagnostics are suppressed on
environments where LLVM_BUILTIN_TRAP is not marked as noreturn.

Diff Detail

Event Timeline

mehdi_amini created this revision.Mar 21 2022, 1:00 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 21 2022, 1:00 PM
mehdi_amini requested review of this revision.Mar 21 2022, 1:00 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 21 2022, 1:00 PM
dexonsmith accepted this revision.Mar 21 2022, 1:07 PM

LGTM!

llvm/include/llvm/Support/ErrorHandling.h
138–141

Maybe worth adding something about warnings?

Something like:

/// ... It conveys intent more clearly, suppresses diagnostics
/// for unreachable code paths, and
/// allows compilers to omit unnecessary code.
This revision is now accepted and ready to land.Mar 21 2022, 1:07 PM
This revision was landed with ongoing or failed builds.Mar 21 2022, 1:50 PM
This revision was automatically updated to reflect the committed changes.
mehdi_amini marked an inline comment as done.Mar 21 2022, 1:50 PM