summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Pavlu <petr.pavlu@arm.com>2018-12-10 15:15:05 +0000
committerPetr Pavlu <petr.pavlu@arm.com>2018-12-10 15:15:05 +0000
commit84e89ff06f74e85ac7a7c677d60f14e9c4e07865 (patch)
tree4cb5ec1eec776a519d4d46cbb2569ba8fe248527
parent4433f93afe901ecd9cc85706ff9c41b79ccbc725 (diff)
downloadbcm5719-llvm-84e89ff06f74e85ac7a7c677d60f14e9c4e07865.tar.gz
bcm5719-llvm-84e89ff06f74e85ac7a7c677d60f14e9c4e07865.zip
[GlobalISel] Set stack protector index when translating Intrinsic::stackprotector
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. Differential Revision: https://reviews.llvm.org/D55418 llvm-svn: 348761
-rw-r--r--llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp12
-rw-r--r--llvm/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator-stackprotect.ll3
2 files changed, 10 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
index 7a39883a56d..dc1e7c3c627 100644
--- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
@@ -973,13 +973,15 @@ bool IRTranslator::translateKnownIntrinsic(const CallInst &CI, Intrinsic::ID ID,
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:
diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator-stackprotect.ll b/llvm/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator-stackprotect.ll
index 62abf3d81d5..ad01264f1a4 100644
--- a/llvm/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator-stackprotect.ll
+++ b/llvm/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
OpenPOWER on IntegriCloud