mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-28 09:31:03 +00:00
Insert functions into the module promptly, not lazily. This fixes a bug
I introduced last night. Note to self: test the *correct* tree... git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12220 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
802b5ab844
commit
63a225050f
@ -1295,8 +1295,6 @@ Module : FunctionList {
|
|||||||
//
|
//
|
||||||
FunctionList : FunctionList Function {
|
FunctionList : FunctionList Function {
|
||||||
$$ = $1;
|
$$ = $1;
|
||||||
assert($2->getParent() == 0 && "Function already in module!");
|
|
||||||
$1->getFunctionList().push_back($2);
|
|
||||||
CurFun.FunctionDone();
|
CurFun.FunctionDone();
|
||||||
}
|
}
|
||||||
| FunctionList FunctionProto {
|
| FunctionList FunctionProto {
|
||||||
@ -1471,18 +1469,13 @@ FunctionHeaderH : TypesV Name '(' ArgList ')' {
|
|||||||
if (!CurFun.isDeclare && !Fn->isExternal())
|
if (!CurFun.isDeclare && !Fn->isExternal())
|
||||||
ThrowException("Redefinition of function '" + FunctionName + "'!");
|
ThrowException("Redefinition of function '" + FunctionName + "'!");
|
||||||
|
|
||||||
// If we found a preexisting function prototype, remove it from the
|
|
||||||
// module, so that we don't get spurious conflicts with global & local
|
|
||||||
// variables.
|
|
||||||
//
|
|
||||||
CurModule.CurrentModule->getFunctionList().remove(Fn);
|
|
||||||
|
|
||||||
// Make sure to strip off any argument names so we can't get conflicts...
|
// Make sure to strip off any argument names so we can't get conflicts...
|
||||||
for (Function::aiterator AI = Fn->abegin(), AE = Fn->aend(); AI != AE; ++AI)
|
for (Function::aiterator AI = Fn->abegin(), AE = Fn->aend(); AI != AE; ++AI)
|
||||||
AI->setName("");
|
AI->setName("");
|
||||||
|
|
||||||
} else { // Not already defined?
|
} else { // Not already defined?
|
||||||
Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName);
|
Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
|
||||||
|
CurModule.CurrentModule);
|
||||||
InsertValue(Fn, CurModule.Values);
|
InsertValue(Fn, CurModule.Values);
|
||||||
CurModule.DeclareNewGlobalValue(Fn, ValID::create($2));
|
CurModule.DeclareNewGlobalValue(Fn, ValID::create($2));
|
||||||
}
|
}
|
||||||
@ -1534,8 +1527,6 @@ Function : BasicBlockList END {
|
|||||||
|
|
||||||
FunctionProto : DECLARE { CurFun.isDeclare = true; } FunctionHeaderH {
|
FunctionProto : DECLARE { CurFun.isDeclare = true; } FunctionHeaderH {
|
||||||
$$ = CurFun.CurrentFunction;
|
$$ = CurFun.CurrentFunction;
|
||||||
assert($$->getParent() == 0 && "Function already in module!");
|
|
||||||
CurModule.CurrentModule->getFunctionList().push_back($$);
|
|
||||||
CurFun.FunctionDone();
|
CurFun.FunctionDone();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user