[llvm-commits] Fix for MachineSink creating zombie defines

Jan Sjodin jan_sjodin at yahoo.com
Fri Jul 29 10:26:36 PDT 2011


This patch fixes a problem with MachineSink. After a critical edge split the flags of the successor were not reflected in the new block, which allowed later instructions to sink even though they write the EFLAGS.
The example below shows the problem. Unfortunately there is a test that relies on this bug, although the problem is that the EFLAGS are live-in when they should not be. The patch disables this test for now.


With the patch the addq and shlq remain above the cmpl instruction.
With patch:
    addq%rax, %rcx
    shlq$4, %rcx
    cmpl$0, (%rdi)
    je.LBB0_2
# BB#1:
    movapd(%rdx,%rcx), %xmm1
    jmp.LBB0_3
.LBB0_2:                                # %entry
    pxor%xmm1, %xmm1
.LBB0_3:                                # %entry
    movapd%xmm1, -128(%rsp)
    jne.LBB0_5


Without the patch the addq and shlq are moved into BB#1 and the jne.LLBB0_5 instruction will do the wrong thing
Before patch: (bad code)
    cmpl$0, (%rdi)
    je.LBB0_2
# BB#1:
    addq%rax, %rcx
    shlq$4, %rcx
    movapd(%rdx,%rcx), %xmm1
    jmp.LBB0_3
.LBB0_2:                                # %entry
    pxor%xmm1, %xmm1
.LBB0_3:                                # %entry
    movapd%xmm1, -128(%rsp)
    jne.LBB0_5
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0050_machinesink.patch
Type: application/octet-stream
Size: 4877 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20110729/77a29a36/attachment.obj>


More information about the llvm-commits mailing list