This is an archive of the discontinued LLVM Phabricator instance.

[clang][SLH] Add __has_feature(speculative_load_hardening)
ClosedPublic

Authored by zbrid on May 11 2020, 11:31 AM.

Details

Summary

SLH doesn't support asm goto and is unlikely to ever support it. Users of asm
goto need a way to choose whether to use asm goto or fallback to an SLH
compatible code path when SLH is enabled. This feature flag will give users
this ability.

Tested via unit test

Diff Detail

Event Timeline

zbrid created this revision.May 11 2020, 11:31 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 11 2020, 11:31 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
zbrid marked an inline comment as done.May 11 2020, 11:31 AM
zbrid added inline comments.
clang/lib/Driver/ToolChains/Clang.cpp
5364–5365

This is a style fix only.

zbrid marked an inline comment as done.May 11 2020, 11:32 AM
zbrid added inline comments.
clang/lib/Driver/ToolChains/Clang.cpp
5364–5365

Err, I mean the change in this line is only a style fix. The rest of the patch is the functional change.

mattdr added inline comments.
clang/include/clang/Basic/LangOptions.def
371

I've read the description of LANGOPT, COMPATIBLE_LANGOPT, and BENIGN_LANGOPT a few times and, though I'm still not confident, I think this should be LANGOPT.

A few reasons:

  1. We actually expect the SLH setting to be the same throughout a compiled binary, so it shouldn't differ between modules and the consequences if it does are already not well defined
  2. Looking through the other BENIGN_LANGOPTs, many seem to describe changing the boundaries for programs that will be accepted/rejected at parsing, which doesn't read on SLH.
  3. We're adding this so we can use __has_feature to change the code that's compiled (e.g. avoiding asm goto), so we definitely anticipate cases where the setting for this option changes the AST in semantic ways

@rsmith -- can you please check my math?

zbrid updated this revision to Diff 263247.May 11 2020, 12:43 PM

Change langopt type + SpeculativeLoadHardeningEnabled -> SpeculativeLoadHardening

This is to match the CodeGenOpt for SLH that already exists and to address
mattdr's feedback.

mattdr accepted this revision.May 11 2020, 1:23 PM
This revision is now accepted and ready to land.May 11 2020, 1:23 PM
zbrid marked an inline comment as done.May 11 2020, 1:36 PM
This revision was automatically updated to reflect the committed changes.