llvm.org GIT mirror llvm / a026cdc
CodeGen: Move the SlotIndexes BumpPtrAllocator before the list it allocates When a `SlotIndexes` is destroyed, `ileAllocator` will currently be destructed before `IndexList`, but all of `IndexList`'s storage has been allocated by `ileAllocator`. This means we'll call destructors on garbage data, which is very bad. This can be avoided by putting the BumpPtrAllocator earlier in the class than anything it allocates. Unfortunately, I don't know how to test this. It depends very much on memory layout, and the only evidence I have that this is actually happening in practice are backtraces that might be explained by this. By inspection though, the code is obviously dangerous/wrong, and this is the right thing to do. I'll follow up later with a patch that calls clearAndLeakNodesUnsafely on the list, since there isn't much point in destructing them when they're allocated in a BPA anyway, but I figured it makes sense to commit the correctness fix separately from that optimization. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254794 91177308-0d34-0410-b5e6-96231b3b80d8 Justin Bogner 4 years ago
1 changed file(s) with 2 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
332332 /// This pass assigns indexes to each instruction.
333333 class SlotIndexes : public MachineFunctionPass {
334334 private:
335 // IndexListEntry allocator.
336 BumpPtrAllocator ileAllocator;
336338 typedef ilist IndexList;
337339 IndexList indexList;
351353 /// Idx2MBBMap - Sorted list of pairs of index of first instruction
352354 /// and MBB id.
353355 SmallVector idx2MBBMap;
355 // IndexListEntry allocator.
356 BumpPtrAllocator ileAllocator;
358357 IndexListEntry* createEntry(MachineInstr *mi, unsigned index) {
359358 IndexListEntry *entry =