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: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to