[llvm-dev] Target triple normalzation through the LLVM C API

Markus Lindström via llvm-dev llvm-dev at lists.llvm.org
Mon Jul 16 03:10:42 PDT 2018


Hello everyone,

First of all, this is my first posting here, so feel free to tell me if I'm asking the wrong questions in the wrong place.

I've discovered that the target triple normalization which used to be done at all times on sys::getDefaultTargetTriple() has been removed, due to the fact that most users of this function explicitly call Triple::normalize() on its result. This has however broken our compiler, which is built upon the LLVM C API, which relied on the default Windows target triple (x86_64-pc-win32 in our case) being normalized to x86_64-pc-windows-msvc. The breakage occurs because the X86 target lowering doesn't consider x86_64-pc-win32 to be an MSVC environment, and it doesn't lower a few instructions including SREM_I64 to MSVC equivalents (_allrem in this case; we end up with __moddi3 instead).

I believe that we should fix this by allowing to invoke the target triple normalization function through the LLVM C API. I would suggest adding an LLVMNormalizeTriple function to the C API (in TargetMachine, I guess) which would wrap Triple::normalize(). Would this be the right way to go about it? If so, we'll propose a patch based on that idea.

Thanks for your help,

Markus Lindström, Raincode Labs (on behalf of LzLabs)
E-mail markus at raincode.com



More information about the llvm-dev mailing list