FunctionPassManager Issue

Hi,

I'm a cs326 student that uses LLVM for our MP. While some of the COOL program can be run seamlessly, I get the following assertion error for many of them.

lli: Pass.cpp:95: bool llvm::FunctionPassManager::run(llvm::Function&):

Assertion `(&F == mF) && "ModuleProvider does not contain this
function!"' failed.

It seems like I need to link a library to it but I'm not sure how to resolve this.

Funny thing, when I use lli -force-interpreter, some of the program runs but have this error message

Tried to execute an unknown external function: sbyte * (sbyte *) * gets

Again, I'd like to know how I should link in the function so that it doesn't complain or fail.

Thank you very much.

Alex

I'm a cs326 student that uses LLVM for our MP. While some of the COOL
program can be run seamlessly, I get the following assertion error for
many of them.

lli: Pass.cpp:95: bool llvm::FunctionPassManager::run(llvm::Function&):
>> Assertion `(&F == mF) && "ModuleProvider does not contain this
>> function!"' failed.

It seems like I need to link a library to it but I'm not sure how to
resolve this.

I really have no idea what is going on here. From my understanding, you
were given a "reduced" version of LLVM to use for CS326. It's quite
possible that there is a problem with the reduction that is causing this.
In any case, without more information (a stack trace from GDB for
example), I can't really diagnose the issue.

Funny thing, when I use lli -force-interpreter, some of the program runs
but have this error message
Tried to execute an unknown external function: sbyte * (sbyte *) * gets

The interpreter is not something that can be relied on, except for trivial
testcases. It does not have a generic "foreign function interface" so it
cannot call external functions that it does not know about.

Again, I'd like to know how I should link in the function so that it
doesn't complain or fail.

Try sending in a stack trace. In particular, run the program in the JIT,
but under gdb:

$ gdb --args lli foo.bc
....

run

...

bt

and send me the output.

Thanks!

-Chris

On most libc implementations, gets is a macro not a function which is
why the FunctionPassManager can't find it. But, if you were compiling
from C, it should never have been requested as a function. Is this in
LLVM assembly that you tried to call gets? If so, that's the problem, it
doesn't (and won't) exist anywhere. Linux has deprecated use of gets
forever. From the man page:

BUGS
       Never use gets(). Because it is impossible to tell without
       knowing the data in advance how many characters gets() will
       read, and because gets() will continue to store characters past
       the end of the buffer, it is extremely dangerous to use. It has
       been used to break computer security. Use fgets() instead.

Reid.