@@ -2301,14 +2301,27 @@ void CIRGenModule::setCXXSpecialMemberAttr(
23012301 }
23022302}
23032303
2304+ static void setWindowsItaniumDLLImport (CIRGenModule &cgm, bool isLocal,
2305+ cir::FuncOp funcOp, StringRef name) {
2306+ // In Windows Itanium environments, try to mark runtime functions
2307+ // dllimport. For Mingw and MSVC, don't. We don't really know if the user
2308+ // will link their standard library statically or dynamically. Marking
2309+ // functions imported when they are not imported can cause linker errors
2310+ // and warnings.
2311+ if (!isLocal && cgm.getTarget ().getTriple ().isWindowsItaniumEnvironment () &&
2312+ !cgm.getCodeGenOpts ().LTOVisibilityPublicStd ) {
2313+ assert (!cir::MissingFeatures::getRuntimeFunctionDecl ());
2314+ assert (!cir::MissingFeatures::setDLLStorageClass ());
2315+ assert (!cir::MissingFeatures::opGlobalDLLImportExport ());
2316+ }
2317+ }
2318+
23042319cir::FuncOp CIRGenModule::createRuntimeFunction (cir::FuncType ty,
23052320 StringRef name, mlir::ArrayAttr,
2306- [[maybe_unused]] bool isLocal,
2321+ bool isLocal,
23072322 bool assumeConvergent) {
23082323 if (assumeConvergent)
23092324 errorNYI (" createRuntimeFunction: assumeConvergent" );
2310- if (isLocal)
2311- errorNYI (" createRuntimeFunction: local" );
23122325
23132326 cir::FuncOp entry = getOrCreateCIRFunction (name, ty, GlobalDecl (),
23142327 /* forVtable=*/ false );
@@ -2317,7 +2330,7 @@ cir::FuncOp CIRGenModule::createRuntimeFunction(cir::FuncType ty,
23172330 // TODO(cir): set the attributes of the function.
23182331 assert (!cir::MissingFeatures::setLLVMFunctionFEnvAttributes ());
23192332 assert (!cir::MissingFeatures::opFuncCallingConv ());
2320- assert (! cir::MissingFeatures::opGlobalDLLImportExport () );
2333+ setWindowsItaniumDLLImport (* this , isLocal, entry, name );
23212334 entry.setDSOLocal (true );
23222335 }
23232336
0 commit comments