@@ -2354,14 +2354,27 @@ void CIRGenModule::setCXXSpecialMemberAttr(
23542354 }
23552355}
23562356
2357+ static void setWindowsItaniumDLLImport (CIRGenModule &cgm, bool isLocal,
2358+ cir::FuncOp funcOp, StringRef name) {
2359+ // In Windows Itanium environments, try to mark runtime functions
2360+ // dllimport. For Mingw and MSVC, don't. We don't really know if the user
2361+ // will link their standard library statically or dynamically. Marking
2362+ // functions imported when they are not imported can cause linker errors
2363+ // and warnings.
2364+ if (!isLocal && cgm.getTarget ().getTriple ().isWindowsItaniumEnvironment () &&
2365+ !cgm.getCodeGenOpts ().LTOVisibilityPublicStd ) {
2366+ assert (!cir::MissingFeatures::getRuntimeFunctionDecl ());
2367+ assert (!cir::MissingFeatures::setDLLStorageClass ());
2368+ assert (!cir::MissingFeatures::opGlobalDLLImportExport ());
2369+ }
2370+ }
2371+
23572372cir::FuncOp CIRGenModule::createRuntimeFunction (cir::FuncType ty,
23582373 StringRef name, mlir::ArrayAttr,
2359- [[maybe_unused]] bool isLocal,
2374+ bool isLocal,
23602375 bool assumeConvergent) {
23612376 if (assumeConvergent)
23622377 errorNYI (" createRuntimeFunction: assumeConvergent" );
2363- if (isLocal)
2364- errorNYI (" createRuntimeFunction: local" );
23652378
23662379 cir::FuncOp entry = getOrCreateCIRFunction (name, ty, GlobalDecl (),
23672380 /* forVtable=*/ false );
@@ -2370,7 +2383,7 @@ cir::FuncOp CIRGenModule::createRuntimeFunction(cir::FuncType ty,
23702383 // TODO(cir): set the attributes of the function.
23712384 assert (!cir::MissingFeatures::setLLVMFunctionFEnvAttributes ());
23722385 assert (!cir::MissingFeatures::opFuncCallingConv ());
2373- assert (! cir::MissingFeatures::opGlobalDLLImportExport () );
2386+ setWindowsItaniumDLLImport (* this , isLocal, entry, name );
23742387 entry.setDSOLocal (true );
23752388 }
23762389
0 commit comments