Fix bug in exception table allocation (PR13678)

Patch by Michael Muller.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172214 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eli Bendersky
2013-01-11 16:33:30 +00:00
parent 8c1e72e6ac
commit dced3cdb04
2 changed files with 67 additions and 10 deletions

View File

@ -969,14 +969,24 @@ bool JITEmitter::finishFunction(MachineFunction &F) {
SavedBufferBegin = BufferBegin;
SavedBufferEnd = BufferEnd;
SavedCurBufferPtr = CurBufferPtr;
uint8_t *FrameRegister;
BufferBegin = CurBufferPtr = MemMgr->startExceptionTable(F.getFunction(),
ActualSize);
BufferEnd = BufferBegin+ActualSize;
EmittedFunctions[F.getFunction()].ExceptionTable = BufferBegin;
uint8_t *EhStart;
uint8_t *FrameRegister = DE->EmitDwarfTable(F, *this, FnStart, FnEnd,
EhStart);
while (true) {
BufferBegin = CurBufferPtr = MemMgr->startExceptionTable(F.getFunction(),
ActualSize);
BufferEnd = BufferBegin+ActualSize;
EmittedFunctions[F.getFunction()].ExceptionTable = BufferBegin;
uint8_t *EhStart;
FrameRegister = DE->EmitDwarfTable(F, *this, FnStart, FnEnd, EhStart);
// If the buffer was large enough to hold the table then we are done.
if (CurBufferPtr != BufferEnd)
break;
// Try again with twice as much space.
ActualSize = (CurBufferPtr - BufferBegin) * 2;
MemMgr->deallocateExceptionTable(BufferBegin);
}
MemMgr->endExceptionTable(F.getFunction(), BufferBegin, CurBufferPtr,
FrameRegister);
BufferBegin = SavedBufferBegin;