This is an archive of the discontinued LLVM Phabricator instance.

Support function attribute patchable_function_entry
ClosedPublic

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

Details

Summary

This feature is generic. Make it applicable for AArch64 and X86 because
the backend has only implemented NOP insertion for AArch64 and X86.

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
Herald added a subscriber: cfe-commits. · View Herald Transcript
MaskRay updated this revision to Diff 236221.Jan 4 2020, 9:18 PM

Move a line from D72222 to D72221

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

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 updated this revision to Diff 236225.Jan 4 2020, 9:44 PM

clang-format

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

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

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

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

ostannard added inline comments.
clang/include/clang/Basic/AttrDocs.td
3995

Grammar nits:
s/attributes/attribute/
over _the_ command line option

clang/lib/CodeGen/CodeGenFunction.cpp
826

I think using two function attributes here would be better, to avoid needing to parse this again later.

clang/lib/Sema/SemaDeclAttr.cpp
4923

Why is the target arch also checked in clang/lib/Driver/ToolChains/Clang.cpp in https://reviews.llvm.org/D72222?

nickdesaulniers marked an inline comment as done.Jan 6 2020, 10:04 AM
nickdesaulniers added inline comments.
clang/lib/Sema/SemaDeclAttr.cpp
4923

Ah, https://reviews.llvm.org/D72221 is checking the __attribute__ syntax, https://reviews.llvm.org/D72222 is checking the command line -f syntax.

clang/lib/CodeGen/CodeGenFunction.cpp
826

In that case, it would not make sense to have start without a size, and thus should be checked for in the verification.

aaron.ballman added inline comments.
clang/include/clang/Basic/Attr.td
686

Should this be inheriting from TargetSpecificAttr as well given that the attribute is only supported on some architectures?

clang/lib/Sema/SemaDeclAttr.cpp
4921

If you make the attribute target-specific, this code can be removed.

4928

Should not be a need to check this -- it will always have at least one argument because the common attribute handling code will diagnose otherwise given the subject list.

clang/test/CodeGen/patchable-function-entry.c
21

Can you also add a test verifying that this attribute works with redeclarations as well? Something like:

[[gnu::patchable_function_entry(12, 4)]] void func(void);

void func(void) { // Definition should have the noop sled
}
MaskRay updated this revision to Diff 236468.Jan 6 2020, 3:06 PM
MaskRay marked 13 inline comments as done.

Address review comments

clang/include/clang/Basic/Attr.td
686

Thanks for the suggestion. Didn't know TargetSpecificAttr.

clang/include/clang/Basic/AttrDocs.td
3995

Thanks. (I am a non-native English speaker and any advice will be highly appreciated.)

(So, I believe GCC's documentation misses _the_)

clang/lib/CodeGen/CodeGenFunction.cpp
826

Agreed. Updated D72215 (semantics of the IR function attribute "patchable-function-entry") as well.

clang/lib/Sema/SemaDeclAttr.cpp
4923

Yes. D72221 is for the Clang function attribute while D72222 is for -fpatchable-function-entry=.

clang/test/CodeGen/patchable-function-entry.c
21
__attribute__((patchable_function_entry(2,0))) void f20decl();
__attribute__((noinline)) void f20decl() {}

Checked this case. I'll delete __attribute__((noinline)) since it does not seem to be clear what it intends to do.

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

failed: Clang.CodeGen/patchable-function-entry.c

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

nickdesaulniers accepted this revision.Jan 8 2020, 9:14 AM

Thanks for all of the work that went into this. Looks like review comments have all been addressed.

This revision is now accepted and ready to land.Jan 8 2020, 9:14 AM
This revision was automatically updated to reflect the committed changes.