Currently, LOAD_STACK_GUARD on ARM is only implemented for Mach-O targets, and
other targets rely on the generic support which may result in spilling of the
stack canary value or address, or may cause it to be kept in a callee save
register across function calls, which means they essentially get spilled as
well, only by the callee when it wants to free up this register.
So let's implement LOAD_STACK GUARD for other targets as well. This ensures
that the load of the stack canary is rematerialized fully in the epilogue.
This code was split off from
D112768: [ARM] implement support for TLS register based stack protector
for which it is a prerequisite.
Other uses of ARMII::MO_COFFSTUB in llvm/lib/Target/ARM/ARMISelLowering.cpp seem to check TargetMachine::shouldAssumeDSOLocal returns false (and GlobalValue::hasDLLImportStorageClass() returns false, too) before setting this flag. Should we be doing so here as well?
To get a reference to the TargetMachine instance, I think we can do:
@peter.smith anyone with more windows on ARM experience that might be able to help triple check this? Probably @mstorsjo ?