[LLVMbugs] [Bug 3556] New: GVN nukes load it shouldn't

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Wed Feb 11 16:27:49 PST 2009


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

           Summary: GVN nukes load it shouldn't
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Scalar Optimizations
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: nlewycky at google.com
                CC: resistor at mac.com, llvmbugs at cs.uiuc.edu


The testcase shows a function @luaO_str2d that calls strtod and strtoul with
nocapture attributes marked on them.

GVN is removing the load of 'char *endptr' after the call to strtod. It's not
allowed to do that as nobody said it wouldn't write to that pointer.

Here's the beginning of the problem function:

define hidden i32 @luaO_str2d(i8* %s, double* nocapture %result) nounwind {
entry:
        %.loc = alloca i8*              ; <i8**> [#uses=2]
        %endptr = alloca i8*, align 8           ; <i8**> [#uses=6]
        %0 = call double @strtod(i8* noalias %s, i8** noalias %endptr) nounwind 
        ; <double> [#uses=1]
        store double %0, double* %result, align 8
        %1 = load i8** %endptr, align 8         ; <i8*> [#uses=1]
        %2 = icmp eq i8* %1, %s         ; <i1> [#uses=1]
        br i1 %2, label %entry.bb12_crit_edge, label %bb1

There's no way GVN could remove %1 here, but it does anyways:

$ opt -gvn b.bc -debug
GVN iteration: 0
GVN removed:    %1 = load i8** %endptr, align 8         ; <i8*> [#uses=0]
GVN REMOVING NONLOCAL LOAD:     %2 = load i8** %endptr, align 8         ; <i8*>
[#uses=1]
GVN removed:    %2 = load i8** %endptr, align 8         ; <i8*> [#uses=0]
GVN REMOVING NONLOCAL LOAD:     %5 = load i8** %endptr, align 8         ; <i8*>
[#uses=1]
GVN removed:    %.rle1 = phi i8* [ undef, %bb1.bb4_crit_edge ], [ undef,
%bb1.bb4_crit_edge1 ]          ; <i8*> [#uses=0]
GVN removed:    %.rle = phi i8* [ undef, %bb4 ], [ undef, %bb1.bb5_crit_edge ]
; <i8*> [#uses=0]
GVN removed:    %5 = load i8** %endptr, align 8         ; <i8*> [#uses=0]
GVN iteration: 1

and I can't seem to make it obviously happen with a smaller testcase (ie., just
the block of .ll quoted with ret i1 %2).


-- 
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