15

C compilers allows to embed assembly code in a C program.

I am pretty sure that Clang should allow embedding LLVM assembly or intrinsic code in C program. How can I embed LLVM assembly in C code?

4

1 Answer 1

9

Right now you can't.

You can, however, write an LLVM assembly function separately in its own file, mark it as alwaysinline, then compile it with the rest of your files - this should get you the same result. See this related question on how to first compile your C files to IR and then link them together.

You can even compile the files separately and make sure you perform link-time optimization (LTO), should do the same thing.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.