[clang] [Clang][CodeGen] Automatically resolve MSVC _hypotf and dllimport for… (PR #207135)
Chuanqi Xu via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 6 18:58:35 PDT 2026
================
@@ -247,10 +247,35 @@ llvm::Constant *CodeGenModule::getBuiltinLibFunction(const FunctionDecl *FD,
Name = Context.BuiltinInfo.getName(BuiltinID).substr(10);
}
+ // If no standard library declaration was found in the AST (freestanding
+ // code calling builtins directly without headers), perform automatic
+ // resolution of MSVC CRT symbol names and DLL import attributes.
+ bool IsNoHeader = (D == GlobalDecl(FD));
+ if (IsNoHeader && getTriple().isWindowsMSVCEnvironment() &&
+ Name == "hypotf") {
+ // Map C99 float math functions to their MSVC CRT prefixed names on Windows.
+ // (Only hypotf needs mapping as it is not exported without prefix in UCRT
+ // on both x86 and x64).
+ Name = "_hypotf";
----------------
ChuanqiXu9 wrote:
I really don't like to hardcoding builtin names here. It looks too ad-hoc.
https://github.com/llvm/llvm-project/pull/207135
More information about the cfe-commits
mailing list