[LLVMdev] Adding intrinsics using an LLVM pass

Rubens Emilio rubenseam at gmail.com
Fri Dec 19 08:44:32 PST 2014


Hey there, guys!

I've added an intrinsic to an input code using an LLVM pass.
I'm able to see the intrinsic call, yet I can't figure out
how to compile the code to my target architecture (x86_64).
I'm running the following command:

    clang++ $(llvm-config --ldflags --libs all) ff.s -o foo

But the linker complains about undefined references:

    /tmp/ff-2ada42.o: In function `fact(unsigned int)':
    /home/rubens/Desktop/ff.cpp:9: undefined reference to
`llvm.x86.sse3.mwait.i32.i32.i32'
    /tmp/ff-2ada42.o: In function `fib(unsigned int)':
    /home/rubens/Desktop/ff.cpp:16: undefined reference to
`llvm.x86.sse3.mwait.i32.i32.i32'
    /home/rubens/Desktop/ff.cpp:16: undefined reference to
`llvm.x86.sse3.mwait.i32.i32.i32'
    /home/rubens/Desktop/ff.cpp:16: undefined reference to
`llvm.x86.sse3.mwait.i32.i32.i32'

Despite using ldflags from llvm-config, the compilation
does not proceed. Any ideas on what should be done
for the code to compile properly?

To generate the assembly code, I've done the following:

    # Generating optimized code
    clang++ $(llvm-config --cxxflags) -emit-llvm -c ff.cpp -o ff.bc
    opt ff.bc -load path/to/mypass.so -mypass > opt_ff.bc

    # Generating assembly
    llc opt_ff.bc -o ff.s

I'm currently using llvm version 3.4.2; clang version 3.4.2
(tags/RELEASE_34/dot2-final); gcc version 4.9.2 (GCC);
and Linux 3.17.2-1-ARCH x86_64.


Regards!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20141219/7dd7dc85/attachment.html>


More information about the llvm-dev mailing list