Skip to content

Commit

Permalink
try to avoid tagging sp-relative accesses
Browse files Browse the repository at this point in the history
sp-relative instructions do not enforce MTE

we check this by seeing if the pointer operand is an AllocaInst; I'm not 100% sure this is sufficient but it seems so thus far
  • Loading branch information
fw-immunant committed Oct 1, 2024
1 parent 05420f8 commit 8759803
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion llvm/lib/Transforms/Utils/AArch64LoadStoreTagging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,13 @@ AArch64LoadStoreTaggingPass::run(Function &F, FunctionAnalysisManager &AM) {
StoreInst *SI = dyn_cast<StoreInst>(&*I);
LoadInst *LI = dyn_cast<LoadInst>(&*I);
if (LI || SI) {
Value *Pointer = SI ? SI->getPointerOperand() : LI->getPointerOperand();
if (AllocaInst *AI = dyn_cast<AllocaInst>(Pointer)) {
continue;
}

IRBuilder<> IRB(&*I);
Value *ReadX18 = readRegister(IRB, "x18");
Value *Pointer = SI ? SI->getPointerOperand() : LI->getPointerOperand();
Value *PtrToInt = IRB.CreatePtrToInt(Pointer, IntptrTy, "makeint");

Value *And = IRB.CreateAnd(ReadX18, TopEightBitsSet, "andhighbitmask");
Expand Down

0 comments on commit 8759803

Please sign in to comment.