mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-01 15:40:55 +03:00
nested: Fix over-zealous invalid frame access check for calling context "root" functions
This commit is contained in:
parent
1359f2a5cd
commit
4cc492b1df
1 changed files with 11 additions and 4 deletions
|
@ -204,14 +204,21 @@ LLValue* DtoNestedContext(Loc& loc, Dsymbol* sym)
|
||||||
|
|
||||||
// Exit quickly for functions that accept a context pointer for ABI purposes,
|
// Exit quickly for functions that accept a context pointer for ABI purposes,
|
||||||
// but do not actually read from it.
|
// but do not actually read from it.
|
||||||
|
//
|
||||||
|
// We cannot simply fall back to retuning undef once we discover that we
|
||||||
|
// don't actually have a context to pass, because we sadly also need to
|
||||||
|
// catch invalid code here in the glue layer (see error() below).
|
||||||
if (FuncDeclaration* symfd = sym->isFuncDeclaration())
|
if (FuncDeclaration* symfd = sym->isFuncDeclaration())
|
||||||
{
|
{
|
||||||
// Make sure we've had a chance to analyze nested context usage
|
// Make sure we've had a chance to analyze nested context usage
|
||||||
DtoCreateNestedContextType(symfd);
|
DtoCreateNestedContextType(symfd);
|
||||||
|
|
||||||
if (getIrFunc(symfd)->depth == -1)
|
int depth = getIrFunc(symfd)->depth;
|
||||||
|
Logger::println("for function of depth %d", depth);
|
||||||
|
if (depth == -1 || (depth == 0 && !symfd->closureVars.empty()))
|
||||||
{
|
{
|
||||||
Logger::println("function does not actually need context, returning undef");
|
Logger::println("function does not have context or creates its own "
|
||||||
|
"from scratch, returning undef");
|
||||||
return llvm::UndefValue::get(getVoidPtrType());
|
return llvm::UndefValue::get(getVoidPtrType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -316,7 +323,7 @@ LLValue* DtoNestedContext(Loc& loc, Dsymbol* sym)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DtoCreateNestedContextType(FuncDeclaration* fd) {
|
static void DtoCreateNestedContextType(FuncDeclaration* fd) {
|
||||||
IF_LOG Logger::println("DtoCreateNestedContextType for %s", fd->toChars());
|
IF_LOG Logger::println("DtoCreateNestedContextType for %s", fd->toPrettyChars());
|
||||||
LOG_SCOPE
|
LOG_SCOPE
|
||||||
|
|
||||||
DtoDeclareFunction(fd);
|
DtoDeclareFunction(fd);
|
||||||
|
@ -429,7 +436,7 @@ static void DtoCreateNestedContextType(FuncDeclaration* fd) {
|
||||||
|
|
||||||
|
|
||||||
void DtoCreateNestedContext(FuncDeclaration* fd) {
|
void DtoCreateNestedContext(FuncDeclaration* fd) {
|
||||||
IF_LOG Logger::println("DtoCreateNestedContext for %s", fd->toChars());
|
IF_LOG Logger::println("DtoCreateNestedContext for %s", fd->toPrettyChars());
|
||||||
LOG_SCOPE
|
LOG_SCOPE
|
||||||
|
|
||||||
DtoCreateNestedContextType(fd);
|
DtoCreateNestedContextType(fd);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue