[LLVMdev] HowToUseJIT: failed assertion on PPC/Mac OS X
Evan Jones
ejones at uwaterloo.ca
Sun Feb 20 09:45:36 PST 2005
On Feb 20, 2005, at 11:12, Evan Jones wrote:
> I can "fix" it by changing JITResolver::getFunctionStub to use
> F->isExternal() instead of F->hasExternalLinkage(). However, this then
> breaks when calling *real* external functions (native code).
I obviously should not post to mailing lists before I've eaten. With my
"fix" I get an assertion when taking an address of a function, not with
native code:
#include <stdio.h>
int foo() {
return 1;
}
int main() {
printf( "%p\n", foo );
return 0;
}
The backtrace is the same as before: a recursive JIT loop. In this
case, F->isExternal() returns "true" because the function has not yet
been loaded (?). A hack to fix both issues is to change the conditional
to test both F->hasExternalLinkage() && F->isExternal().
I don't quite get what is going on here. From what I understand,
external linkage means that the function is visible outside the current
module? So a function declared in a C file would have external
linkage, while a "static" function would have internal linkage. The
GlobalValue::isExternal() method should return true if the global value
is defined outside the current translation unit.
From my understanding, "foo()"->isExternal() should return *false*,
since it is defined in the current translation unit. However, it
doesn't because none of the basic blocks for the body have not yet been
loaded (?).
At any rate, I've attached a new patch which "works for me" on PPC and
x86. At this point, I really don't know what is going on, so I really
don't know if it is correct.
Evan Jones
-------------- next part --------------
A non-text attachment was scrubbed...
Name: JITEmitter.patch
Type: application/octet-stream
Size: 920 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20050220/57c1f5e7/attachment.obj>
More information about the llvm-dev
mailing list