Nothing print out by opt -load

I’m trying to use the optimization by using shared object.

the command I try is: opt -load=LLVMHello.so input.ll

But there is nothing printing out.

The output maybe the functions name in the input.ll Like opt -passes=helloworld input.ll

I enter the command llvm-config --shared-mode to check the status, and it print out shared.

How can I fix it?

Hey @shane87123 !

opt -load=LLVMHello.so input.ll

This command does not specify which pass to run :slight_smile:

-Andrzej

2 Likes

Sorry for asking such a stupid question.

A can answer myself after trying the opt tool in these days.

In my experiments, It’s not necessary to use opt -load=file.so to plugin the shared-object file only using opt -passes=pass.

If your LLVM compilers build by “share-library”, it used the shared-object files.

In this question, the way to use the LLVMHello.so can just be opt -passes=helloworld input.ll.

To check this feature, we can build two different LLVMHello.so files with different things to do, and just replace each other in llvm-project/build/lib/LLVMHello.so to switch the shared-object files.

For example: Now I have two helloworld shared-object files - LLVMHello_1.so and LLVMHello_2.so

$ cp LLVMHello_1.so ~/llvm-project/build/lib/LLVMHello.so
$ opt -passes=helloworld input.ll
## Do the things what LLVMHello_1.so does ##

$ cp LLVMHello_2.so ~/llvm-project/build/lib/LLVMHello.so
$ opt -passes=helloworld input.ll
## Do the things what LLVMHello_2.so does ##

No question is stupid. Just ask! Maybe others have the same question as yours.