[PATCH] D55418: [GlobalISel] Set stack protector index when translating Intrinsic::stackprotector
Petr Pavlu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 7 02:04:45 PST 2018
petpav01 created this revision.
petpav01 added reviewers: t.p.northover, aemerson.
Herald added subscribers: llvm-commits, arphaman, javed.absar, kristof.beyls, rovka.
Record the stack protector index in `MachineFrameInfo` when translating `Intrinsic::stackprotector` similarly as is done by SelectionDAG when processing the same intrinsic.
Setting this index allows the Prologue/Epilogue Insertion to recognize that the stack protection is enabled. The pass can then make sure that the stack protector comes before local variables on the stack and assigns potentially vulnerable objects first so they are close to the stack protector slot.
Repository:
rL LLVM
https://reviews.llvm.org/D55418
Files:
lib/CodeGen/GlobalISel/IRTranslator.cpp
test/CodeGen/AArch64/GlobalISel/arm64-irtranslator-stackprotect.ll
Index: test/CodeGen/AArch64/GlobalISel/arm64-irtranslator-stackprotect.ll
===================================================================
--- test/CodeGen/AArch64/GlobalISel/arm64-irtranslator-stackprotect.ll
+++ test/CodeGen/AArch64/GlobalISel/arm64-irtranslator-stackprotect.ll
@@ -3,6 +3,9 @@
; CHECK: name: test_stack_guard
+; CHECK: frameInfo:
+; CHECK: stackProtector: '%stack.0.StackGuardSlot'
+
; CHECK: stack:
; CHECK: - { id: 0, name: StackGuardSlot, type: default, offset: 0, size: 8, alignment: 8,
; CHECK-NOT: id: 1
Index: lib/CodeGen/GlobalISel/IRTranslator.cpp
===================================================================
--- lib/CodeGen/GlobalISel/IRTranslator.cpp
+++ lib/CodeGen/GlobalISel/IRTranslator.cpp
@@ -968,13 +968,15 @@
getStackGuard(GuardVal, MIRBuilder);
AllocaInst *Slot = cast<AllocaInst>(CI.getArgOperand(1));
+ int FI = getOrCreateFrameIndex(*Slot);
+ MF->getFrameInfo().setStackProtectorIndex(FI);
+
MIRBuilder.buildStore(
GuardVal, getOrCreateVReg(*Slot),
- *MF->getMachineMemOperand(
- MachinePointerInfo::getFixedStack(*MF,
- getOrCreateFrameIndex(*Slot)),
- MachineMemOperand::MOStore | MachineMemOperand::MOVolatile,
- PtrTy.getSizeInBits() / 8, 8));
+ *MF->getMachineMemOperand(MachinePointerInfo::getFixedStack(*MF, FI),
+ MachineMemOperand::MOStore |
+ MachineMemOperand::MOVolatile,
+ PtrTy.getSizeInBits() / 8, 8));
return true;
}
case Intrinsic::cttz:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55418.177148.patch
Type: text/x-patch
Size: 1657 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181207/80e2dbba/attachment.bin>
More information about the llvm-commits
mailing list