[LLVMdev] viewCFG call from opt loaded shared lib

Kelly Wilson wilsonk at cpsc.ucalgary.ca
Sun Oct 29 22:45:39 PST 2006


Hey everyone,

I want to call F.viewCFG() from within the Hello.so shared library 
runOnFunction() function, but I keep getting:

opt: symbol lookup error: ../../../Debug/lib/LLVMHello.so: undefined 
symbol: _ZNK4llvm8Function7viewCFGEv

while using:

"opt -load ../../../Debug/lib/LLVMHello.so -print 
/temp/llvm/KellyTest/test.bc"


I assume this means that I need to statically link in 
LLVMAnalysis.a/LLVMCodeGen.a where viewCFG is located. I changed the 
Makefile by adding these libs to the LLVMlibs variable and 
recompiled successfully. I still get the same error, though.

I look at the VERBOSE=1 output for make and the "-lLLVMAnalysis 
-lLLVMCodeGen" linking is not done. I tried it manually but I still get 
this error.

What I want to do is load Hello.so using opt, and then

1. run part way through runOnFunction()
2. print out the CFG
3. modify the CFG (ie. SplitCriticalEdges or something)
4. loop to 2.

I also tried to run opt inside gdb and break at runOnfunction(). This
gives me a warning:

Function "runOnFunction" not defined.
Make breakpoint pending on future shared library load? (y or [n])

I choose y but there is no breakpoint set. If I can get this break point 
then I can manually call viewCFG() (once the libs are statically linked, I 
guess).

Any ideas,
K.Wilson

P.S. I know that I can push Hello.cpp into the llvm/lib/Transforms/... 
directory, recompile and then use opt with the -hello option (then I get 
the graph output I want). It just takes A LONG TIME to recompile 
everything that depends on the Scalar lib stuff. Trying to speed up the 
compile-link-run cycle here.





More information about the llvm-dev mailing list