This is an archive of the discontinued LLVM Phabricator instance.

[Clang FE] Recognize -mnop-mcount CL option
ClosedPublic

Authored by jonpa on Sep 19 2019, 7:42 AM.

Details

Summary

Recognize -mnop-mcount from the command line and add a function attribute "mnop-mcount"="true" when passed.

When this option is passed, a nop is added instead of a call to fentry. This is used when building the Linux Kernel.

I followed the steps of fentry and implemented this the same way. The (SystemZ) backend can recognize the function attribute and output the nop instead of the call (patch pending). Is this approach acceptable?

Diff Detail

Event Timeline

jonpa created this revision.Sep 19 2019, 7:42 AM
jonpa added a comment.Sep 19 2019, 7:46 AM

See https://reviews.llvm.org/D67765 for the SystemZ backend part of this patch set.

jonpa updated this revision to Diff 221742.Sep 25 2019, 6:27 AM

Check that -mnop-mcount is only passed for systemz, and check as well that -fentry was passed.

Otherwise this looks good to me, but it might be better to get approval from a front-end expert as well.

lib/CodeGen/CodeGenFunction.cpp
899

Why not use diag::err_opt_not_valid_without_opt here?

jonpa updated this revision to Diff 221898.Sep 26 2019, 2:01 AM
jonpa marked 2 inline comments as done.

Use a new diag::err_opt_not_valid_without_opt value instead of "..._with_opt"

lib/CodeGen/CodeGenFunction.cpp
899

yes, it seems needed, so I added it now in DiagnosticCommonKinds.td.

uweigand added inline comments.Sep 26 2019, 2:24 AM
lib/CodeGen/CodeGenFunction.cpp
899

Ah, I still saw it in my tree, it was just removed as unused a week ago :-)

jonpa edited subscribers, added: cfe-commits; removed: llvm-commits.Sep 30 2019, 12:37 AM

@benjamin: I see that you removed the option that I am now putting back, so perhaps you could take a look and see if this patch looks ok? Thanks. /Jonas

uweigand accepted this revision.Nov 4 2019, 11:20 AM

This looks good to me now. Given that this patch implements an option only relevant on SystemZ, this should be OK.

This revision is now accepted and ready to land.Nov 4 2019, 11:20 AM
jonpa closed this revision.Nov 5 2019, 3:15 AM

committed as 9376714