Skip to content

Commit c180e24

Browse files
authored
Fix crash lowering stack guard on OpenBSD/aarch64. (llvm#125416)
TargetLoweringBase::getIRStackGuard refers to a platform-specific guard variable. Before this change, TargetLoweringBase::getSDagStackGuard only referred to a different variable. This means that SelectionDAGBuilder's getLoadStackGuard does not get memory operands. However, AArch64InstrInfo::expandPostRAPseudo assumes that the passed MachineInstr has nonzero memoperands, causing a segfault. We have two possible options here: either disabling the LOAD_STACK_GUARD node entirely in AArch64TargetLowering::useLoadStackGuardNode or just making the platform-specific values match across TargetLoweringBase. Here, we try the latter.
1 parent 87602f6 commit c180e24

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

llvm/lib/CodeGen/TargetLoweringBase.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2005,6 +2005,9 @@ void TargetLoweringBase::insertSSPDeclarations(Module &M) const {
20052005
// Currently only support "standard" __stack_chk_guard.
20062006
// TODO: add LOAD_STACK_GUARD support.
20072007
Value *TargetLoweringBase::getSDagStackGuard(const Module &M) const {
2008+
if (getTargetMachine().getTargetTriple().isOSOpenBSD()) {
2009+
return M.getNamedValue("__guard_local");
2010+
}
20082011
return M.getNamedValue("__stack_chk_guard");
20092012
}
20102013

0 commit comments

Comments
 (0)