This is an archive of the discontinued LLVM Phabricator instance.

[X86] Support function attribute "patchable-function-entry"
ClosedPublic

Authored by MaskRay on Jan 4 2020, 9:05 PM.

Details

Summary

For x86-64, we diverge from GCC -fpatchable-function-entry in that we
emit multi-byte NOPs.

Diff Detail

Event Timeline

MaskRay created this revision.Jan 4 2020, 9:05 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 4 2020, 9:05 PM

Unit tests: fail. 61247 tests passed, 1 failed and 736 were skipped.

failed: LLVM.CodeGen/X86/patchable-function-entry.ll

clang-tidy: fail. Please fix clang-tidy findings.

clang-format: fail. Please format your changes with clang-format by running git-clang-format HEAD^ or applying this patch.

Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

MaskRay added a comment.EditedJan 4 2020, 9:32 PM

The GCC implementer did the work for Linux kernel AArch64. They probably did not think of x86 multi-byte NOP. Currently this feature is only used by the Linux kernel on arm64/parisc. I asked whether the x86 implementation should be improved https://gcc.gnu.org/ml/gcc/2020-01/msg00020.html

We don't support M!=0 (-fpatchable-function-entry=N,M). If we do, its interaction with -falign-functions=32 will be interesting. GCC apparently just simply aligns the first NOP, so the function symbol may be misaligned.

craig.topper added inline comments.Jan 4 2020, 9:35 PM
llvm/lib/Target/X86/X86MCInstLower.cpp
1601

is this longer than 80 columns?

MaskRay updated this revision to Diff 236226.Jan 4 2020, 9:45 PM

clang-format

MaskRay marked an inline comment as done.Jan 4 2020, 9:45 PM

Unit tests: pass. 61250 tests passed, 0 failed and 736 were skipped.

clang-tidy: fail. Please fix clang-tidy findings.

clang-format: pass.

Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

This revision is now accepted and ready to land.Jan 5 2020, 9:11 PM
nickdesaulniers added inline comments.
llvm/lib/Target/X86/X86MCInstLower.cpp
1604

Sounds like this may be updated based on @ostannard 's comment in https://reviews.llvm.org/D72215#inline-653987.

MaskRay updated this revision to Diff 236529.Jan 6 2020, 11:59 PM

Implement .section __patchable_function_entries,"aw",@progbits

Unit tests: pass. 61276 tests passed, 0 failed and 736 were skipped.

clang-tidy: fail. Please fix clang-tidy findings.

clang-format: pass.

Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

llvm/lib/Target/X86/X86MCInstLower.cpp
1607

Can llvm::Attribute::getValueAsInt() be used here?

This revision was automatically updated to reflect the committed changes.

Unit tests: pass. 61759 tests passed, 0 failed and 780 were skipped.

clang-tidy: fail. Please fix clang-tidy findings.

clang-format: pass.

Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml