[LLVMbugs] [Bug 14849] New: Dragonegg's miscompilation in C++

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Jan 8 05:40:00 PST 2013


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

             Bug #: 14849
           Summary: Dragonegg's miscompilation in C++
           Product: dragonegg
           Version: trunk
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: New Bugs
        AssignedTo: baldrick at free.fr
        ReportedBy: geek4civic at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


/* testcase derived from clang/lib/AST/DeclObjC.cpp */

struct X {
  virtual void* getXXX();
};

template<void* (X::*Get)()>
struct LazyOffsetPtr {
  void* get(X *Source) {
    return (Source->*Get)();
  }
};

void *g(LazyOffsetPtr<&X::getXXX>& Body, X* x) {
  return Body.get(x);
}

--
I won't create more reduced case. Possibly combination of vptr, method pointer,
template.

gcc-4.7.0
dragonegg trunk
host: x86-64

-- dragonegg (gcc-4.7) -O3
  %0 = getelementptr inbounds %struct.X* %x, i64 0, i32 0
  %1 = load i32 (...)*** %0, align 8
  %2 = load i32 (...)** %1, align 8
  %3 = tail call i32 (...)* %2(%struct.X* %x)
  ret i8* undef
; why %3 is i32?
; also -O0 emits invalid code.

-- clang -O3
  %1 = bitcast %struct.X* %x to i8**
  %2 = load i8** %1, align 8
  %3 = bitcast i8* %2 to i8* (%struct.X*)**
  %4 = load i8* (%struct.X*)** %3, align 8
  %5 = tail call i8* %4(%struct.X* %x) nounwind
  ret i8* %5

-- g++-4.7.0
        movq    (%rsi), %rax
        movq    %rsi, %rdi
        movq    (%rax), %rax
        jmp     *%rax

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