[llvm] [hwasan] Add intrinsics for fixed shadow on Aarch64 (PR #89319)
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 22 18:23:57 PDT 2024
================
@@ -625,14 +638,35 @@ void AArch64AsmPrinter::emitHwasanMemaccessSymbols(Module &M) {
.addImm(4)
.addImm(55),
*STI);
- OutStreamer->emitInstruction(
- MCInstBuilder(AArch64::LDRBBroX)
- .addReg(AArch64::W16)
- .addReg(IsShort ? AArch64::X20 : AArch64::X9)
- .addReg(AArch64::X16)
- .addImm(0)
- .addImm(0),
- *STI);
+
+ if (IsFixedShadow) {
+ // Aarch64 makes it difficult to embed large constants in the code.
+ // Fortuitously, kShadowBaseAlignment == 32, so we use the 32-bit
+ // left-shift option in the MOV instruction. Combined with the 16-bit
+ // immediate, this is enough to represent any offset up to 2**48.
+ OutStreamer->emitInstruction(MCInstBuilder(AArch64::MOVZXi)
+ .addReg(AArch64::X17)
+ .addImm(FixedShadowOffset >> 32)
----------------
vitalybuka wrote:
we probably want a diagnostics
`((FixedShadowOffset >> 32) << 32) == FixedShadowOffset`
and request shadow 32bit aligned
or change intrinsic to 16imm for real
https://github.com/llvm/llvm-project/pull/89319
More information about the llvm-commits
mailing list