[LLVMdev] bug in the JIT global variable emitter
evan.cheng at apple.com
Thu Oct 16 09:06:52 PDT 2008
Thanks Nuno and Dale. Some comments:
+ /// allocateSpace - reserves space in the current block if any, or
+ /// allocate a new one of the given size + virtual void
*allocateSpace(intptr_t Size, unsigned Alignment); +
Please capitalize "reserves".
+ /// allocateSpace - general-purpose space allocator
Better comments please. :-) Also please end the sentence with a period
or Chris' head will explode. :-)
unsigned char *result = (unsigned char *)CurBlock+1;
+ if (Alignment == 0) Alignment = 1;
+ result = (unsigned char*)(((intptr_t)result+Alignment-1) &
If type of result is intptr_t, you can avoid some of the casting, right?
On Oct 16, 2008, at 8:45 AM, Nuno Lopes wrote:
>>> Ok, thanks for the explanation. So my first patch doesn't work.
>>> Also, to be
>>> clear, this bug has nothing to do with overflowing the JIT memory
>>> I made another one that takes keeps the allocation of global
>>> variables in
>>> the JIT buffer, but it creates a new mem block if it doesn't exist
>>> when dumping a global variable out of the scope of a function
>>> The patch is at:
>> OK, I think I finally understand this: the allocation in
>> JIT::getOrEmitGlobalVariable doesn't call into JITEmitter but uses
>> MachineCodeEmitter directly. Thus, if you call it from outside the
>> JITEmitter, it won't update the data structures the JITEmitter relies
>> on. In the usual case, the JITEmitter calls into JIT and updates
>> own data structures, so that case works fine.
> exactly! :) Thank you for summarizing. I hope others can now follow
>> I think adding a smarter allocateSpace to JITEmitter is the right
>> general idea, and your patch looks OK. I'd like to get another pair
>> of eyes on it though, as I find this area not straightfoward:)
>> run the testsuite before committing.
> Yes, I would also appreciate more reviewers. The JIT's code is
> complex and I'm also quite new to the LLVM code..
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev