-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CHERI-RISC-V] Add a target feature to no longer assume ISAv8 semantics #708
Conversation
0db0587
to
3852466
Compare
a173037
to
1ac5ee9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general looks fine to me, but I don't know the LLVM bits well enough to give a qualified review.
1ac5ee9
to
d9f4b09
Compare
@jrtc27 ping? Would be great to get this merged soon. |
llvm/lib/Target/RISCV/RISCV.td
Outdated
def FeatureNoCheriV8Compat | ||
: SubtargetFeature<"xcheri-no-v8-compat", "HasCheriISAv8Semantics", "false", | ||
"CHERI ISAv8 semantics (trapping, DDC/PCC relocation)">; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TableGen, subtarget feature and Subtarget variable names are all pairwise inconsistent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I originally started with a positive V9 semantics flag, but that did not out for some reason I've now forgotten since it's been a while. I think it caused problems when I tried to introduce the xcherimin feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be better now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This duplicates what's in init.c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is required due to the --implicit-check-not=
, I could restrict it to lowercase cheri, but I think it's helpful to have all macros that include CHERI to be checked here.
f7cd93e
to
19a41d6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more minor points, ok to merge once fixed
When set, this feature allows the compiler to assume new capability semantics (tag-clearing instead of trapping and removal of DDC/PCC relocation). This will allow hoisting previously trapping instructions out of loops which cannot be done unconditionally now as we still want to support building and running the last CheriBSD release with the latest dev branch of the compiler. We therefore need an opt-in flag that can be set by the CheriBSD build system.
When +xcheri-v9-semantics is set, we can assume that all capability modification instruction no longer trap. This is currently done in the isGuaranteedNotToTrap() hook, but once ISAv8 semantics are no longer supported we should update the tablegen instruction definitions to remove the mayTrap flag. This allows hoisting a few more instructions in MachineLICM which results in minor code quality improvements (for example 19 new machinelicm.NumHoisted in SPEC2k6 483.xalancbmk)
CToPtr will be removed from the CHERI-RISC-V ISA in the future and will not be part of a standardized version. We emit a branch-less form of `x.tag ? x.addr : 0` when we see the intrinsic in ISAv9 compilation mode instead. When expanding `ptrtoint` in hybrid mode we also no longer subtract the base of DDC as part of the expansion, since DDC relocation is no longer part of xcherimin, and subtracting the base would result in an integer that points to a different address when dereferenced. This behaviour is consistent with Morello when CCTLR.DDCBO is disabled.
We emit `x == 0 ? null : CSetAddrt(auth, x)` when we see the intrinsic in non-ISAv8 compilation mode instead. We use CSetAddr instead of CSetOffset as adding the base would result in a capability that points to a different address when dereferenced. This change in intrinsic behaviour is consistent with Morello where the resulting CVT instruction takes the DDC relocation configuration (CCTLR.DDCBO) into account. It would be nice if we could just use `CSetAddr(DDC, x)` unconditionally for non-constant `inttoptt` arguments, but that could result in semantic differences (tagged vs untagged zero) for integers that happen to be zero at run time.
This will be extended to show new macros to detect missing ISAv8 compat. This duplicates some checks from init.c, but this is required to ensure exhaustive checking with --implicit-check-not
This defines two new macros, `__riscv_xcheri_no_relocation` and `__riscv_xcheri_tag_clear` when the target feature +xcheri-no-v8-compat is enabled.
This will be removed once we default to the new semantics. This also adds a mxcheri-v8-compat flag to opt-in to the old semantics (although that is currently the default).
19a41d6
to
7fe8d14
Compare
When set, this feature allows the compiler to assume new capability
semantics (tag-clearing instead of trapping and removal of DDC/PCC
relocation). This will allow hoisting previously trapping instructions
out of loops which cannot be done unconditionally now as we still want
to support building and running the last CheriBSD release with the latest
dev branch of the compiler. We therefore need an opt-in flag that can be
set by the CheriBSD build system.
This PR makes use of this target feature to assume non-trapping semantics for capability modification instructions which results in minor changes to codegen for Spec2k6.