Set FnEnd in JITEmitter::finishFunction to point strictly to the end of function's machine code.

Don't include memory allocated for global variables during relocations resolution.

llvm-svn: 70517
This commit is contained in:
Argyrios Kyrtzidis 2009-04-30 23:01:58 +00:00
parent a088693557
commit 30481e275c
1 changed files with 6 additions and 3 deletions

View File

@ -1051,6 +1051,9 @@ bool JITEmitter::finishFunction(MachineFunction &F) {
unsigned char *FnStart =
(unsigned char *)TheJIT->getPointerToGlobalIfAvailable(F.getFunction());
// FnEnd is the end of the function's machine code.
unsigned char *FnEnd = CurBufferPtr;
if (!Relocations.empty()) {
CurFn = F.getFunction();
NumRelos += Relocations.size();
@ -1128,9 +1131,9 @@ bool JITEmitter::finishFunction(MachineFunction &F) {
}
}
unsigned char *FnEnd = CurBufferPtr;
MemMgr->endFunctionBody(F.getFunction(), BufferBegin, FnEnd);
// CurBufferPtr may have moved beyond FnEnd, due to memory allocation for
// global variables that were referenced in the relocations.
MemMgr->endFunctionBody(F.getFunction(), BufferBegin, CurBufferPtr);
if (CurBufferPtr == BufferEnd) {
// FIXME: Allocate more space, then try again.