[LLVMbugs] [Bug 17070] New: inline function seems generating wrong code

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Sep 2 19:51:03 PDT 2013


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

            Bug ID: 17070
           Summary: inline function seems generating wrong code
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: manjian2006 at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 11135
  --> http://llvm.org/bugs/attachment.cgi?id=11135&action=edit
The preprocessed source & llvm IR source

The generated IR of heapSort is wrong in this line:
the inline function swap
        swap(start[endIndex], start[0]);
the llvm code looks like this:
define linkonce_odr hidden void
@_ZN3WTF8heapSortIPNS_6OwnPtrIN7WebCore13MediaQueryExpEEEPFbRKS4_S7_EEEvT_SA_T0_(%"class.WTF::OwnPtr.1"*
%start, %"class.WTF::OwnPtr.1"* %end, i1 (%"class.WTF::OwnPtr.1"*,
%"class.WTF::OwnPtr.1"*)* nocapture %compareLess) #0 {

...

.lr.ph:                                           ; preds =
%_ZN3WTF7heapifyIPNS_6OwnPtrIN7WebCore13MediaQueryExpEEEPFbRKS4_S7_EEEvT_iT0_.exit.preheader
  %34 = getelementptr inbounds %"class.WTF::OwnPtr.1"* %start, i32 0, i32 0
  br label %35

; <label>:35                                      ; preds = %.lr.ph,
%_ZN3WTF7heapifyIPNS_6OwnPtrIN7WebCore13MediaQueryExpEEEPFbRKS4_S7_EEEvT_iT0_.exit.backedge
  %endIndex.04 = phi i32 [ %endIndex.02.pre-phi, %.lr.ph ], [ %endIndex.0,
%_ZN3WTF7heapifyIPNS_6OwnPtrIN7WebCore13MediaQueryExpEEEPFbRKS4_S7_EEEvT_iT0_.exit.backedge
]
  %endIndex.0.in3 = phi i32 [ %4, %.lr.ph ], [ %endIndex.04,
%_ZN3WTF7heapifyIPNS_6OwnPtrIN7WebCore13MediaQueryExpEEEPFbRKS4_S7_EEEvT_iT0_.exit.backedge
]
  %36 = getelementptr inbounds %"class.WTF::OwnPtr.1"* %start, i32
%endIndex.04, i32 0
  %37 = load %"class.WebCore::MediaQueryExp"** %36, align 4, !tbaa !3
  store %"class.WebCore::MediaQueryExp"* %37, %"class.WebCore::MediaQueryExp"**
%34, align 4, !tbaa !3
  %38 = add nsw i32 %endIndex.0.in3, -2
  %39 = icmp slt i32 %38, 1
  br i1 %39, label
%_ZN3WTF7heapifyIPNS_6OwnPtrIN7WebCore13MediaQueryExpEEEPFbRKS4_S7_EEEvT_iT0_.exit.backedge,
label %.lr.ph.i1



As you can see swap function involve two load insts and two store insts,but
just one of them is generated.Please check this bug.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130903/8a3689d0/attachment.html>


More information about the llvm-bugs mailing list