[PATCH] D125916: [PowerPC] Defined and lowered llvm.ppc.kill.canary intrinsic
Paul Scoropan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 18 11:38:25 PDT 2022
pscoro created this revision.
Herald added subscribers: shchenz, kbarton, hiraditya, nemanjai.
Herald added a project: All.
pscoro requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D125916
Files:
llvm/include/llvm/IR/IntrinsicsPowerPC.td
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp
===================================================================
--- llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -11103,6 +11103,43 @@
}
break;
}
+ case Intrinsic::ppc_kill_canary: {
+ MachineFunction &MF = DAG.getMachineFunction();
+ if (MF.getFunction().hasFnAttribute(Attribute::SafeStack)) {
+ break;
+ }
+
+ MachineFrameInfo &MFI = MF.getFrameInfo();
+ int SPI = MFI.getStackProtectorIndex(); // should return -1
+
+ PPCFunctionInfo *FuncInfo = MF.getInfo<PPCFunctionInfo>();
+ EVT PtrVT = getPointerTy(MF.getDataLayout());
+ SDValue FIN = DAG.getFrameIndex(FuncInfo->getVarArgsFrameIndex(), PtrVT); // frame index
+
+ unsigned int deadBird = 0x4C6C566D; // replaces canary word
+
+ SDValue Store = DAG.getStore( // create store instr, stores (deadBird + 0) into addr (frame index + stack protector)
+ Op->getOperand(0),
+ DL,
+ DAG.getNode( // add deadBird, 0, return node result
+ ISD::ADD,
+ DL,
+ PtrVT,
+ DAG.getConstant(deadBird, DL, PtrVT),
+ DAG.getConstant(0, DL, PtrVT)
+ ),
+ DAG.getNode( // add frame index, stack protector index, return node result
+ ISD::ADD,
+ DL,
+ PtrVT,
+ FIN,
+ DAG.getConstant(SPI, DL, PtrVT)
+ ),
+ MachinePointerInfo()
+ );
+ return Store;
+ break;
+ }
default:
break;
}
Index: llvm/include/llvm/IR/IntrinsicsPowerPC.td
===================================================================
--- llvm/include/llvm/IR/IntrinsicsPowerPC.td
+++ llvm/include/llvm/IR/IntrinsicsPowerPC.td
@@ -217,6 +217,10 @@
: Intrinsic<[llvm_float_ty],
[llvm_float_ty, llvm_float_ty, llvm_float_ty, llvm_vararg_ty],
[IntrNoMem]>;
+ def int_ppc_kill_canary
+ : Intrinsic<[],
+ [],
+ [IntrWriteMem, IntrHasSideEffects]>;
}
let TargetPrefix = "ppc" in { // All PPC intrinsics start with "llvm.ppc.".
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125916.430467.patch
Type: text/x-patch
Size: 2197 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220518/4eafa009/attachment.bin>
More information about the llvm-commits
mailing list