[llvm-dev] Issue with HelloWorld pass

Mehdi Amini via llvm-dev llvm-dev at lists.llvm.org
Tue Aug 2 18:18:44 PDT 2016


> On Aug 2, 2016, at 6:12 PM, Alessandro Fanfarillo via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> Dear all,
> I'm new to the LLVM world and I'm trying to run reproduce the hello
> world example described here
> http://llvm.org/releases/3.8.1/docs/WritingAnLLVMPass.html.
> 
> I started with a fresh new llvm-3.8.1 installation based on cmake
> (running on Linux x86) using the following command:
> 
> cmake -DCMAKE_INSTALL_PREFIX=/path/to/llvm -DLLVM_TARGETS_TO_BUILD="X86" ../
> 
> The build directory was inside the top directory of the llvm-3.8.1 source.
> 
> I copied and pasted the pass example reported at the end of the "Basic
> code required" section and I managed to compile everything correctly
> with CMake.
> Because there is already a Hello example (with the correspondent
> LLVMHello.so file), I decided to call it NewHello.
> 
> When I try to test the pass with the following string
> 
> opt -load /path/to/llvm-3.8.1.src/build/lib/LLVMNewHello.so -hello <
> new_hello.bc > /dev/null

Is “opt” here the same version as LLVMNewHello.so?

> 
> I get the following error:
> Expected no forward declarations!
> !0 = <temporary!> !{}
> incorrect number of operands in llvm.ident metadata
> !0 = <temporary!> !{}
> opt: -: error: input module is broken!
> 
> I've also tried with the LLVMHello.so file but I got the same error message.
> 
> Do you have any suggestions?

Does round-tripping without loading your own pass work?
Something like: opt < new_hello.bc > /dev/null

How did you generate the new_hello.bc file?
Did you use clang? If so, did you use the same version of clang as your opt and your pass?

— 
Mehdi



More information about the llvm-dev mailing list