[LLVMbugs] [Bug 3100] New: llvm-g++ is unable to devirtualize a	function call
    bugzilla-daemon at cs.uiuc.edu 
    bugzilla-daemon at cs.uiuc.edu
       
    Wed Nov 19 06:56:04 PST 2008
    
    
  
http://llvm.org/bugs/show_bug.cgi?id=3100
           Summary: llvm-g++ is unable to devirtualize a function call
           Product: tools
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: llvm-g++
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: rafael.espindola at gmail.com
                CC: llvmbugs at cs.uiuc.edu
Testcase from the g++ testsuite
-----------------------------------------
struct S { S(); virtual void xyzzy(); };
inline void foo(S *s) { s->xyzzy(); }
void bar() { S s; foo(&s); }
----------------------------------------
With gcc we got
call    _ZN1S5xyzzyEv
with llvm-g++ we got
call    *%rax
there rax contains the pointer fetched from the vtable. The problem is that
llvm-g++ knows what the vtable looks like, but doesn't communicate that to
llvm.
A simpler testcase also fails with llvm:
----------------------------------------
struct S { S() {}; virtual void xyzzy(); };
inline void foo(S *s) { s->xyzzy(); }
void bar() { S s; foo(&s); }
----------------------------------------
Now we have the constructor body and we do a bit better:
----------------------------
call    *_ZTV1S+16
---------------------------
but llvm-g++ only says
@_ZTV1S = external constant [3 x i32 (...)*]
so there is no way for llvm to const propagate the fetch.
-- 
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