This is an archive of the discontinued LLVM Phabricator instance.

[BOLT] Fix trap value for non-X86
ClosedPublic

Authored by treapster on Aug 17 2023, 8:45 AM.

Details

Summary

The trap value used by BOLT was assumed to be single-byte instruction. It made some functions unaligned on AArch64(e.g exceptions-instrumentation test with AArch64 instrumentation) and caused emission failures. Fix that by changing fill value to target-specific StringRef. Since AArch64 instrumentation is not merged yet, here i use mark-funcs option to trigger the bug and provide a testcase.

Diff Detail

Event Timeline

treapster created this revision.Aug 17 2023, 8:45 AM
Herald added a reviewer: Amir. · View Herald Transcript
Herald added a reviewer: maksfb. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
treapster requested review of this revision.Aug 17 2023, 8:45 AM
treapster updated this revision to Diff 551716.Aug 19 2023, 1:04 AM

clang-format

rafauler accepted this revision.Aug 22 2023, 2:31 PM

LGTM. Thanks!

bolt/lib/Core/BinaryEmitter.cpp
383

Note: I'm guessing this is not accounted for in LongJmp.cpp.. this will be one source of mismatched layout between what LongJmp thinks the layout will be and what the layout really is, leading to missing trampolines in some cases.

This is a point in favor of maybe trying to insert the trampolines in JITLink maybe, as syncing LongJmp's understanding of the layout with what actually is happening in BOLT's emitter is a hard task.

This revision is now accepted and ready to land.Aug 22 2023, 2:31 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptAug 23 2023, 3:32 PM