[llvm-dev] libcalls vs. size of int

Anatoly Trosinenko via llvm-dev llvm-dev at lists.llvm.org
Wed Mar 24 07:21:33 PDT 2021


Hi!

> I guess one solution here is to find all the builtins in compiler-rt that isn't using machine mode types and put them in a list of functions that depend on size of int/long etc. Then make sure we make those unavailable for targets with int!=si_int etc (and then one has to implement an replacement if those functions are needed).

> Another solution could be to break compatibility with libgcc and use the machine mode types everywhere (or is there a requirement that builtins are compatible between libclang_rt and libgcc?).

I do not have some definitive solution right now, but the third option could probably be implementing several compiler-rt functions such as __powsidf2 (normally aliased with __powidf2) and __powhidf2 (aliased with __powidf2 on 16-bit targets). This makes possible to only emit calls to machine mode-sized helper functions from `llc`. At the same time one will not end up having two functions with the same name in libgcc and compiler-rt and subtle differences in behavior.

Since there are no such functions in libgcc, llc would have to emit different names when using compiler-rt and libgcc. Unfortunately, it seems the knowledge whether we are targeting libgcc or compiler-rt as a support library is lost at the time of codegen. As a workaround, llc could emit calls to the aforementioned overloaded functions only if `sizeof(void*) < 32` (this should be easily accessible via DataLayout). This may be considered as a limited/explicit "breaking compatibility with libgcc" but looks rather hackish.

Anatoly


More information about the llvm-dev mailing list