[LLVMbugs] [Bug 3784] New: PHIElimination incorrect in presence of exception handling

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Wed Mar 11 06:16:31 PDT 2009


http://llvm.org/bugs/show_bug.cgi?id=3784

           Summary: PHIElimination incorrect in presence of exception
                    handling
           Product: new-bugs
           Version: unspecified
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: baldrick at free.fr
                CC: llvmbugs at cs.uiuc.edu


Created an attachment (id=2700)
 --> (http://llvm.org/bugs/attachment.cgi?id=2700)
testcase .ll

This commit

r66140 | evancheng | 2009-03-05 07:31:26 +0100 (Thu, 05 Mar 2009) | 2 lines
Do not split edges to EH landing pads. It will cause code size explosion.

broke several tests in the Ada testsuite by exposing a latent bug in
PHIElimination.  The basic problem is that the PHIElimination pass
inserts register copies at the end of basic blocks, which means after
any invoke instruction.  But if the phi is in a landing pad then the
copy needs to be made before the invoke call, not after.  Probably the
pass should just skip phi's that occur in landing pads.

In the testcase you can see this in the basic block bb2.
In the machine function, register %reg1027 is used in the
landing pad (lpad) in a phi node.  Here is bb2 before phi
elimination.  The CALLpcrel32 <ga:__gnat_rcheck_02> is the
invoke, which causes execution to branch to lpad.

bb2: 0x9ee7a98, LLVM BB @0x9ec35c0, ID#4:
    Predecessors according to CFG: 0x9ee7a48 (#3)
        %reg1027<def> = MOV32rr %reg1025<kill>   
        EH_LABEL 5                               
        ADJCALLSTACKDOWN32 8, %ESP<imp-def>, %EFLAGS<imp-def,dead>,
%ESP<imp-use>
        %reg1063<def> = MOV32rr %ESP                                            
        MOV32mi %reg1063, 1, %reg0, 4, 35, Mem:ST(4,4) [Stack + 4]              
        MOV32mi %reg1063<kill>, 1, %reg0, 0, <ga:.str>, Mem:ST(4,4) [Stack + 0] 
        CALLpcrel32 <ga:__gnat_rcheck_02>, ...
        ADJCALLSTACKUP32 8, 0, %ESP<imp-def>, %EFLAGS<imp-def,dead>,
%ESP<imp-use>                                                                   
        EH_LABEL 6                                                              
        JMP mbb<invcont3,0x9ee7ae8>                                             
    Successors according to CFG: 0x9ee7ae8 (#5) 0x9ee8448 (#37)                 

And here it is after phi elimination.  Phi elimination has
inserted a copy of %reg1027 to %reg1099 at the end of the
basic block, but it occurs too late: the value is needed in
the landing pad so the copy needs to occur before the call.

bb2: 0x991ea48, LLVM BB @0x98fa5c0, ID#4:
    Predecessors according to CFG: 0x991e9f8 (#3)
        %reg1027<def> = MOV32rr %reg1025<kill>   
        EH_LABEL 5                               
        ADJCALLSTACKDOWN32 8, %ESP<imp-def>, %EFLAGS<imp-def,dead>,
%ESP<imp-use>
        %reg1063<def> = MOV32rr %ESP                                            
        MOV32mi %reg1063, 1, %reg0, 4, 35, Mem:ST(4,4) [Stack + 4]              
        MOV32mi %reg1063<kill>, 1, %reg0, 0, <ga:.str>, Mem:ST(4,4) [Stack + 0] 
        CALLpcrel32 <ga:__gnat_rcheck_02>, %EAX<imp-def,dead>,
%ECX<imp-def,dead>, %EDX<imp-def,dead>, %FP0<imp-def,dead>, %FP1<imp-def,dead>,
%FP2<imp-def,dead>, %FP3<imp-def,dead>, %FP4<imp-def,dead>, %FP5<imp-def,dead>,
%FP6<imp-def,dead>, %ST0<imp-def>, %MM0<imp-def,dead>, %MM1<imp-def,dead>,
%MM2<imp-def,dead>, %MM3<imp-def,dead>, %MM4<imp-def,dead>, %MM5<imp-def,dead>,
%MM6<imp-def,dead>, %MM7<imp-def,dead>, %XMM0<imp-def,dead>,
%XMM1<imp-def,dead>, %XMM2<imp-def,dead>, %XMM3<imp-def,dead>,
%XMM4<imp-def,dead>, %XMM5<imp-def,dead>, %XMM6<imp-def,dead>,
%XMM7<imp-def,dead>, %XMM8<imp-def,dead>, %XMM9<imp-def,dead>,
%XMM10<imp-def,dead>, %XMM11<imp-def,dead>, %XMM12<imp-def,dead>,
%XMM13<imp-def,dead>, %XMM14<imp-def,dead>, %XMM15<imp-def,dead>,
%EFLAGS<imp-def,dead>, %ESP<imp-use>                                            
        ADJCALLSTACKUP32 8, 0, %ESP<imp-def>, %EFLAGS<imp-def,dead>,
%ESP<imp-use>                                                                   
        EH_LABEL 6                                                              
        %reg1099<def> = MOV32rr %reg1027<kill>                                  
        JMP mbb<invcont3,0x991ea98>                                             
    Successors according to CFG: 0x991ea98 (#5) 0x991f3f8 (#37)


-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list