LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 5116 - x86-64 JIT omits stubs in some cases they're needed
Summary: x86-64 JIT omits stubs in some cases they're needed
Status: RESOLVED FIXED
Alias: None
Product: libraries
Classification: Unclassified
Component: Backend: X86 (show other bugs)
Version: trunk
Hardware: PC Linux
: P normal
Assignee: Unassigned LLVM Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-01 17:11 PDT by Jeffrey Yasskin
Modified: 2009-10-05 19:37 PDT (History)
5 users (show)

See Also:
Fixed By Commit(s):


Attachments
JITTest.cpp addition to provoke the bug (2.81 KB, patch)
2009-10-01 17:11 PDT, Jeffrey Yasskin
Details
Fix by removing "!TheJIT->isLazyCompilationDisabled()" (3.41 KB, patch)
2009-10-01 17:47 PDT, Jeffrey Yasskin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jeffrey Yasskin 2009-10-01 17:11:55 PDT
Created attachment 3598 [details]
JITTest.cpp addition to provoke the bug

The attached unit test generates the following assembly:

0x00007ffff7f45010 <test+0>:    sub    $0x8,%rsp
0x00007ffff7f45014 <test+4>:    mov    $0x7,%edi                                          
0x00007ffff7f45019 <test+9>:    callq  0x800000427cd8
0x00007ffff7f4501e <test+14>:   add    $0x8,%rsp                                          
0x00007ffff7f45022 <test+18>:   retq

where the intended target function is actually at address 0x427cd8. This appears to be happening because the actual 64-bit offset gets truncated to 32 bits when it's stored into the callq instruction.  This will only happen on x86-64 systems when JIT code is allocated into memory far away from the pre-compiled code segment.  If lazy compilation is enabled, or the function is looked up via dlsym instead of addGlobalMapping, the error doesn't happen.
Comment 1 Jeffrey Yasskin 2009-10-01 17:47:26 PDT
Created attachment 3599 [details]
Fix by removing "!TheJIT->isLazyCompilationDisabled()"

This fixes the unittest I added and doesn't break `make check-lit unittests`. If it's going to break something else, could you provide a unittest?
Comment 2 Jeffrey Yasskin 2009-10-05 19:37:39 PDT
I've applied the fix in r83353.