[PATCH] D57183: [COFF, ARM64] Fix localaddress to handle stack realignment
Mandeep Singh Grang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 25 14:19:41 PST 2019
mgrang added a comment.
In the existing code, there are several conditions on when FP/BP/SP should be used. I have tried to summarize them here:
use BP:
if ((hasVarSizedObjects || hasEHFunclets)) && (needsStackRealignment || LocalFrameSize >= 256))
use FP:
if (hasEHFunclets || hasVarSizedObjects || needsStackRealignment || hasLocalEscape ||
hasCalls || isFrameAddressTaken || hasStackMap || hasPatchPoint || !MaxCallFrameSizeComputed ||
MaxCallFrameSize > DefaultSafeSPDisplacement)
else use SP
Here's my understanding of how the locals should be accessed in various scenarios:
struct S { int x; };
// Use FP to access escaped locals: (hasFunclets = true, hasVarSizedObjects = false, needsStackRealignment = false)
void simple() {
struct S o;
__try { o.x; }
__finally { o.x; }
}
// Use BP to access escaped locals: (hasFunclets = true, hasVarSizedObjects = false, needsStackRealignment = true)
void stack_realignment() {
struct S __declspec(align(32)) o;
__try { o.x; }
__finally { o.x; }
}
// Use BP to access escaped locals: (hasFunclets = true, hasVarSizedObjects = true, needsStackRealignment = false)
void vla_present(int n) {
int vla[n];
__try { vla[0]; }
__finally { vla[0]; }
}
// Use BP to access escaped locals: (hasFunclets = true, hasVarSizedObjects = true, needsStackRealignment = true)
void all(int n) {
struct S __declspec(align(32)) o;
int vla[n];
__try { o.x; vla[0]; }
__finally { o.x; vla[0]; }
}
// Use SP to access locals: (hasFunclets = false, hasVarSizedObjects = false, needsStackRealignment = false)
void non_seh() {
// call to llvm.localaddress();
}
Could you please comment on if all the scenarios have been captured here and if the behavior is what is expected?
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D57183/new/
https://reviews.llvm.org/D57183
More information about the llvm-commits
mailing list