Folding instructions on X86

Dear LLVMers,

      I need help with one error in my register allocator. I am getting
errors when folding instructions for the x86 (it does not happen when
I use the PowerPC as target). The problem is that, when I execute
something like: mi = mbb->insert(mbb->erase(mi), fmi), where mbb is a MachineBasicBlock, valgrind gives this error message:

Address 0x42C62B0 is 24 bytes inside a block of size 28 free'd

     at 0x401C35D: operator delete(void*)(vg_replace_malloc.c:244)
     by 0x83E4A7B: llvm::iplist<llvm::MachineInstr,
llvm::ilist_traits<llvm::MachineInstr>

::erase(llvm::ilist_iterator<llvm::MachineInstr>) (ilist:323)

     by 0x83E464D: llvm::MachineBasicBlock::erase(llvm::ilist_iterator<llvm::MachineInstr>) (MachineBasicBlock.h:168)

Do you guys know any possible reason of why this would happen when producing code for the X86, but not for the PowerPC?

Best regards,

Fernando

Fernando Magno Quintao Pereira wrote:

Dear LLVMers,

      I need help with one error in my register allocator.

Out of curiosity, what kind of register allocator is that?

- Volodya

     I need help with one error in my register allocator. I am getting
errors when folding instructions for the x86 (it does not happen when
I use the PowerPC as target). The problem is that, when I execute
something like: mi = mbb->insert(mbb->erase(mi), fmi), where mbb is a
MachineBasicBlock, valgrind gives this error message:

Address 0x42C62B0 is 24 bytes inside a block of size 28 free'd

    at 0x401C35D: operator delete(void*)(vg_replace_malloc.c:244)
    by 0x83E4A7B: llvm::iplist<llvm::MachineInstr,
llvm::ilist_traits<llvm::MachineInstr>

::erase(llvm::ilist_iterator<llvm::MachineInstr>) (ilist:323)

    by 0x83E464D:
llvm::MachineBasicBlock::erase(llvm::ilist_iterator<llvm::MachineInstr>)
(MachineBasicBlock.h:168)

It's hard to say, but it seems that the pointer to erase is most likely invalid.

Do you guys know any possible reason of why this would happen when
producing code for the X86, but not for the PowerPC?

X86 has many more instructions that can be folded than powerpc does. You're probably just happening to get unlucky on x86.

-Chris