[LLVMbugs] [Bug 13516] New: JIT always emits far calls

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Aug 2 08:25:47 PDT 2012


             Bug #: 13516
           Summary: JIT always emits far calls
           Product: libraries
           Version: trunk
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Target-Independent JIT
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: nunoplopes at sapo.pt
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

I got this e-mail from Tim Starling (reproduced with authorization):

I think that the problem is probably exhaustion of the branch target
buffer. In x86-64 with CodeModel::Large, every call becomes
register-indirect, like:

0x400dc10e: movabs $0x40090bb0,%rax
0x400dc118: mov %r14,%rdi
0x400dc11b: mov %rbx,%rsi
0x400dc11e: callq *%rax

Based on my reading of the Intel optimization reference manual, each
such call site will use up a slot in the branch target buffer. Intel
doesn't include the size of it on their spec sheets or in the
optimization manual, but other sources say that it has 512 entries,
except for a few very recent processors which have 1024 entries.

I tried using CodeModel::Small, but it just caused an assert error
when it encountered calls to functions outside of RIP+2GB, instead of
upgrading them to register-indirect calls:

php: X86CodeEmitter.cpp:477:
llvm::MachineInstr&, unsigned int, unsigned int, intptr_t) [with
CodeEmitter = llvm::JITCodeEmitter]: Assertion `IndexReg.getReg() == 0
&& Is64BitMode && "Invalid rip-relative address"' failed.
Stack dump:
0.    Running pass 'X86 Machine Code Emitter' on function

Apparently there is no support in LLVM for some calls being short and
some being long. When code is compiled with clang or llc, it can use
CodeModel::Small and rely on the fact that all calls to code outside
of the 2GB neighbourhood will be via the PLT.

CodeModel::JITDefault is apparently a hack to work around the lack of
awareness of the RIP address in X86DAGToDAGISel. Any LLVM JIT will
have the same performance issue when more than 512 call instructions
appear in a loop.

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