[PATCH] D17740: [SSP, 2/2] Load the correct stack guard values on PowerPC
Tim Shen via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 29 13:58:48 PST 2016
timshen created this revision.
timshen added a reviewer: echristo.
timshen added subscribers: llvm-commits, iteratee, hfinkel, kbarton, joerg.
Let PowerPC handle LOAD_STACK_GUARD manually, since glibc isn't offering a __stack_chk_guard symbol, but put it in TCB.
http://reviews.llvm.org/D17740
Files:
lib/Target/PowerPC/PPCISelLowering.h
lib/Target/PowerPC/PPCInstrInfo.cpp
lib/Target/PowerPC/PPCInstrInfo.h
test/CodeGen/PowerPC/stack-protector.ll
Index: test/CodeGen/PowerPC/stack-protector.ll
===================================================================
--- test/CodeGen/PowerPC/stack-protector.ll
+++ test/CodeGen/PowerPC/stack-protector.ll
@@ -1,5 +1,8 @@
-; RUN: llc -march=ppc32 -mtriple=ppc32-unknown-linux < %s | FileCheck %s
-; CHECK: __stack_chk_guard
+; RUN: llc -march=ppc32 -mtriple=ppc32-unknown-linux < %s | FileCheck -check-prefix=PPC32 %s
+; RUN: llc -mtriple=powerpc64le-unknown-linux < %s | FileCheck -check-prefix=PPC64LE %s
+
+; PPC32: ld {{[0-9]+}}, -28680(2)
+; PPC64LE: ld {{[0-9]+}}, -28688(13)
; CHECK: __stack_chk_fail
@"\01LC" = internal constant [11 x i8] c"buf == %s\0A\00" ; <[11 x i8]*> [#uses=1]
Index: lib/Target/PowerPC/PPCInstrInfo.h
===================================================================
--- lib/Target/PowerPC/PPCInstrInfo.h
+++ lib/Target/PowerPC/PPCInstrInfo.h
@@ -272,6 +272,8 @@
ArrayRef<std::pair<unsigned, const char *>>
getSerializableBitmaskMachineOperandTargetFlags() const override;
+
+ bool expandPostRAPseudo(MachineBasicBlock::iterator MI) const override;
};
}
Index: lib/Target/PowerPC/PPCInstrInfo.cpp
===================================================================
--- lib/Target/PowerPC/PPCInstrInfo.cpp
+++ lib/Target/PowerPC/PPCInstrInfo.cpp
@@ -1846,3 +1846,17 @@
return makeArrayRef(TargetFlags);
}
+bool PPCInstrInfo::expandPostRAPseudo(MachineBasicBlock::iterator MI) const {
+ switch (MI->getOpcode()) {
+ case TargetOpcode::LOAD_STACK_GUARD: {
+ const int64_t Offset = Subtarget.isPPC64() ? -0x7010 : -0x7008;
+ const unsigned Reg = Subtarget.isPPC64() ? PPC::X13 : PPC::R2;
+ MI->setDesc(get(PPC::LD));
+ MachineInstrBuilder(*MI->getParent()->getParent(), MI)
+ .addImm(Offset)
+ .addReg(Reg);
+ return true;
+ }
+ }
+ return false;
+}
Index: lib/Target/PowerPC/PPCISelLowering.h
===================================================================
--- lib/Target/PowerPC/PPCISelLowering.h
+++ lib/Target/PowerPC/PPCISelLowering.h
@@ -672,6 +672,10 @@
unsigned
getExceptionSelectorRegister(const Constant *PersonalityFn) const override;
+ virtual Value *getStackGuardAddr(Module &M) const override {
+ return nullptr;
+ }
+
private:
struct ReuseLoadInfo {
SDValue Ptr;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17740.49423.patch
Type: text/x-patch
Size: 2304 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160229/14418500/attachment.bin>
More information about the llvm-commits
mailing list