[llvm-commits] Fwd: Re: [LLVMdev] [PATCH] Fix for bug in JIT exception table allocation
Duncan Sands
baldrick at free.fr
Thu Sep 13 03:16:46 PDT 2012
Hi Michael,
> --- lib/ExecutionEngine/JIT/JITEmitter.cpp (revision 163478)
> +++ lib/ExecutionEngine/JIT/JITEmitter.cpp (working copy)
> @@ -974,14 +974,24 @@
> 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 we've run out of memory, try again with twice as much space.
> + if (CurBufferPtr == BufferEnd) {
> + ActualSize = (CurBufferPtr-BufferBegin)*2;
> + MemMgr->deallocateExceptionTable(BufferBegin);
> + } else {
> + break;
> + }
here I think it would be more conformant with LLVM style to do:
// 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);
Otherwise looks good to me, though that's not saying much since I don't know
this part of LLVM.
Ciao, Duncan.
> + }
> MemMgr->endExceptionTable(F.getFunction(), BufferBegin, CurBufferPtr,
> FrameRegister);
> BufferBegin = SavedBufferBegin;
More information about the llvm-commits
mailing list