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; Index: lib/Target/PowerPC/PPCInstrInfo.h =================================================================== --- lib/Target/PowerPC/PPCInstrInfo.h +++ lib/Target/PowerPC/PPCInstrInfo.h @@ -272,6 +272,8 @@ ArrayRef> 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: 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]