This is an archive of the discontinued LLVM Phabricator instance.

[X86] Support ``-mindirect-branch-cs-prefix`` for call and jmp to indirect thunk
ClosedPublic

Authored by pengfei on Jul 29 2022, 2:54 AM.

Diff Detail

Event Timeline

pengfei created this revision.Jul 29 2022, 2:54 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 29 2022, 2:54 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
pengfei requested review of this revision.Jul 29 2022, 2:54 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJul 29 2022, 2:54 AM
nickdesaulniers accepted this revision.Aug 1 2022, 2:22 PM

LGTM; thanks for the patch!

This revision is now accepted and ready to land.Aug 1 2022, 2:23 PM

When a module with "indirect_branch_cs_prefix" and another without the module flag are merged, what the result should be? If 0, we should use Min instead of Override.

MaskRay requested changes to this revision.Aug 2 2022, 12:29 AM
MaskRay added inline comments.
clang/lib/Driver/ToolChains/Clang.cpp
6362

Check CC1Option uses in clang/include/clang/Driver/Options.td

This revision now requires changes to proceed.Aug 2 2022, 12:29 AM
pengfei updated this revision to Diff 449275.Aug 2 2022, 6:22 AM
pengfei marked an inline comment as done.

Add CC1 option test.

When a module with "indirect_branch_cs_prefix" and another without the module flag are merged, what the result should be? If 0, we should use Min instead of Override.

I think Override is correct. This option is used for Linux Kernel build. When merged, all should be set to 1.

MaskRay added inline comments.Aug 2 2022, 1:28 PM
clang/lib/Driver/ToolChains/Clang.cpp
6362

This is not needed with the TableGen CC1Option change.

pengfei added inline comments.Aug 3 2022, 2:08 AM
clang/lib/Driver/ToolChains/Clang.cpp
6362

Do you have an example how to change the CC1Option? Removing the code directly won't generate the expected module flag anymore.

MaskRay accepted this revision.Aug 3 2022, 4:12 PM
MaskRay added inline comments.
clang/lib/Driver/ToolChains/Clang.cpp
6362

OK, sorry. A statement is needed: Args.AddLastArg(CmdArgs, options::OPT_mindirect_branch_cs_prefix);

clang/test/Driver/x86_features.c
15

Use --target=i386 instead of legacy -target

This revision is now accepted and ready to land.Aug 3 2022, 4:12 PM
This revision was landed with ongoing or failed builds.Aug 4 2022, 12:17 AM
This revision was automatically updated to reflect the committed changes.
pengfei marked an inline comment as done.

Thanks for review!

clang/lib/Driver/ToolChains/Clang.cpp
6362

Good to know such usage. Thank you!

nikic added a subscriber: nikic.Aug 4 2022, 11:49 PM

This change caused a significant compile-time regression for O0 builds (about 1%): http://llvm-compile-time-tracker.com/compare.php?from=45bae1be90472c696f6ba3bb4f8fabee76040fa9&to=6f867f9102838ebe314c1f3661fdf95700386e5a&stat=instructions

At a guess, fetching a module flag for every single instruction is slow?

This change caused a significant compile-time regression for O0 builds (about 1%): http://llvm-compile-time-tracker.com/compare.php?from=45bae1be90472c696f6ba3bb4f8fabee76040fa9&to=6f867f9102838ebe314c1f3661fdf95700386e5a&stat=instructions

At a guess, fetching a module flag for every single instruction is slow?

Thanks for reporting it. I guess so. I'll try to move it outside :)

This change caused a significant compile-time regression for O0 builds (about 1%): http://llvm-compile-time-tracker.com/compare.php?from=45bae1be90472c696f6ba3bb4f8fabee76040fa9&to=6f867f9102838ebe314c1f3661fdf95700386e5a&stat=instructions

At a guess, fetching a module flag for every single instruction is slow?

Thanks for reporting it. I guess so. I'll try to move it outside :)

D131245 should help with it.