This is an archive of the discontinued LLVM Phabricator instance.

[Driver] Correct -f(no-)xray-function-index behavior
AbandonedPublic

Authored by ilammy on Mar 11 2023, 7:52 AM.

Details

Summary

This option has undergone several refactorings and got inverted along
the way. The XRayOmitFunctionIndex flag governs codegen behavior,
*omitting* "xray_fn_idx" section if it is set. But the command-line
flag behavior was not adjusted at the time. Right now it's like this:

               (default): no function index
   -fxray-function-index: no function index
-fno-xray-function-index: "xray_fn_idx" is present

While the default behavior should be keep "xray_fn_idx", unless
-fno-xray-function-index is given:

               (default): "xray_fn_idx" is present
   -fxray-function-index: same, present, but explicitly
-fno-xray-function-index: no function index

Flip the flags to make it so.

Diff Detail

Event Timeline

ilammy created this revision.Mar 11 2023, 7:52 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 11 2023, 7:52 AM
Herald added a subscriber: arphaman. · View Herald Transcript
ilammy requested review of this revision.Mar 11 2023, 7:52 AM
ianlevesque accepted this revision.Mar 11 2023, 1:18 PM

Good catch, thanks for the fix.

This revision is now accepted and ready to land.Mar 11 2023, 1:18 PM
MaskRay requested changes to this revision.Mar 11 2023, 11:05 PM
MaskRay added inline comments.
clang/test/CodeGen/xray-function-index.cpp
2

Add // REQUIRES: x86-registered-target

9

.section xray_fn_idx

This revision now requires changes to proceed.Mar 11 2023, 11:05 PM
ilammy updated this revision to Diff 504609.Mar 13 2023, 5:35 AM

Addressed feedback by @MaskRay. Thanks!

MaskRay accepted this revision.Mar 13 2023, 10:14 PM

Thanks!

clang/test/CodeGen/xray-function-index.cpp
2

Move // REQUIRES: to the top

This revision is now accepted and ready to land.Mar 13 2023, 10:14 PM
ilammy updated this revision to Diff 530284.Jun 11 2023, 12:28 AM

Addressing feedback by @MaskRay:

  • Moved // REQUIRES: directive to the top of the test file
ilammy marked 3 inline comments as done.Jun 11 2023, 12:29 AM
MaskRay added inline comments.Jun 11 2023, 1:09 PM
clang/test/CodeGen/xray-function-index.cpp
1

We generally want to avoid assembly output tests in clang/test.

However, CodeGenOpts.XRayOmitFunctionIndex only affects llvm::TargetOptions, not LLVM IR, so I think this seems fine.

(Note: a lot of xray tests do not follow the best practice, and we should be careful for new tests, not necessarily copying the old xray testing practice.)

2

We don't usually do alignment like this. You may place -S earlier to make the compile action (emit assembly) clearer.

This option has undergone several refactorings and got inverted along the way. The XRayOmitFunctionIndex flag governs codegen behavior, *omitting* "xray_fn_idx" section if it is set. But the command-line flag behavior was not adjusted at the time. Right now it's like this:

d8a8e5d6240a1db809cd95106910358e69bbf299 accidentally omitted xray_fn_idx by default.
I pushed 849f1dd15e92fda2b83dbb6144e6b28b2cb946e0 to rename the confusing XRayOmitFunctionIndex and fix -fno-xray-function-index/-fxray-function-index.

MaskRay added inline comments.Jun 11 2023, 3:31 PM
clang/include/clang/Driver/Options.td
2219

The change should be accompanies by a change to clang/lib/Driver/XRayArgs.cpp.
I'll fix this issue myself.
Thanks for reporting the bug, though.

ilammy abandoned this revision.Jun 15 2023, 5:13 PM

@MaskRay, thanks!