Skip to content

Commit be4097b

Browse files
3405691582tstellar
authored andcommitted
Fix crash lowering stack guard on OpenBSD/aarch64. (#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. (cherry picked from commit c180e24)
1 parent aecbb23 commit be4097b

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
@@ -1987,6 +1987,9 @@ void TargetLoweringBase::insertSSPDeclarations(Module &M) const {
19871987
// Currently only support "standard" __stack_chk_guard.
19881988
// TODO: add LOAD_STACK_GUARD support.
19891989
Value *TargetLoweringBase::getSDagStackGuard(const Module &M) const {
1990+
if (getTargetMachine().getTargetTriple().isOSOpenBSD()) {
1991+
return M.getNamedValue("__guard_local");
1992+
}
19901993
return M.getNamedValue("__stack_chk_guard");
19911994
}
19921995

0 commit comments

Comments
 (0)