[LLVMdev] Custom allocators for MachineBasicBlocks and STL containers

Jakob Stoklund Olesen jolesen at apple.com
Fri Feb 14 15:40:03 PST 2014


On Feb 14, 2014, at 3:34 PM, Evan Cheng <evan.cheng at apple.com> wrote:

> 
> On Feb 14, 2014, at 1:52 PM, Eli Bendersky <eliben at google.com> wrote:
> 
>> Hello,
>> 
>> I was looking at how the memory for MachineBasicBlocks is managed and something seems strange.
>> 
>> On one hand, a MachineFunction uses a recycling allocator to create and destroy MBBs without costly heap allocation (the same is done for MachineInstrs, MachineOperands, etc.).
>> 
>> On the other hand, each MBB also has a number of STL vectors within it. For example, for Predecessors, Successors, Weights, LiveIns. Maintaining these vectors involves heap allocation and they don't have custom allocators, AFAICS.  
>> 
>> Is there some magic I'm missing here, or does this make little sense?
> 
> Jakob would know for sure. My guess is it takes time to move all the data structure over to the custom allocators so we just tackled the ones that provide the most bang for the buck.

What Evan said.

The MachineInstr class is completely heap independent. It would be nice to do the same for MBB, but the gains are small.

Thanks,
/jakob




More information about the llvm-dev mailing list