Why and from what is Compiler-RT called?

I would like to know the following about the LLVM Compiler-RT project: from which program it is called. As far as I understand, Compiler-RT is a set of functions that process instructions in LLVM, which in fact have no hardware analogues (is there more for this?). Therefore, if I use division in LLVM, it should be replaced with the corresponding compiler-RT function. Firstly, if this is not correct, please correct me!

Secondly, I'm curious who generates the use of compiler-RT. This is Clang or this is LLVM directly. Can I write a different interface for LLVM and will LLVM automatically handle using compiler-RT, if necessary?

+6
source share
1 answer

Both of your statements are true. The LLVM backend must map the LLVM IR to its own target instructions. If the instruction is not supported initially, it must be replaced (legalized). You can see this happening in TargetLowering , which directly maps the runtime functions to the RT Compiler .

The front part is not involved.

+5
source

Source: https://habr.com/ru/post/953268/


All Articles