This is an archive of the discontinued LLVM Phabricator instance.

[BOLT] Fix empty function emission in non-relocation mode
ClosedPublic

Authored by maksfb on Sep 15 2022, 2:15 PM.

Details

Summary

In non-relocation mode, every function is emitted in its own section. If
a function is empty, RuntimeDyld will still allocate 1-byte section
for the function and initialize it with zero. As a result, we will
overwrite the first byte of the original function contents with zero.
Such scenario can happen when the input function had only NOP
instructions which BOLT removes by default. Even though such functions
likely cause undefined behavior, it's better to preserve their contents.

Diff Detail

Event Timeline

maksfb created this revision.Sep 15 2022, 2:15 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 15 2022, 2:15 PM
Herald added a subscriber: treapster. · View Herald Transcript
maksfb requested review of this revision.Sep 15 2022, 2:15 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 15 2022, 2:15 PM
yota9 accepted this revision.Sep 15 2022, 3:15 PM
This revision is now accepted and ready to land.Sep 15 2022, 3:15 PM
This revision was automatically updated to reflect the committed changes.