From 9b721c98f7ed618749510d1a3280205ad58cf551 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Thu, 25 Apr 2019 23:30:41 +0000 Subject: [PATCH] Revert [COFF] Statically link certain runtime library functions This reverts r359250 (git commit 4730604bd3a361c68b92b18bf73a5daa15afe9f4) The newly added test should use -cc1 and -emit-llvm and there are other test failures that need fixing. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@359251 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CodeGenModule.cpp | 10 +++------- test/CodeGen/ms-symbol-linkage.cpp | 20 -------------------- test/CodeGenCXX/runtime-dllstorage.cpp | 2 +- test/CodeGenObjC/gnu-init.m | 4 ++-- test/CodeGenObjCXX/msabi-stret.mm | 3 ++- 5 files changed, 8 insertions(+), 31 deletions(-) delete mode 100644 test/CodeGen/ms-symbol-linkage.cpp diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index b490fa0faf..e51963aa9a 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -3000,13 +3000,9 @@ CodeGenModule::CreateRuntimeFunction(llvm::FunctionType *FTy, StringRef Name, if (F->empty()) { F->setCallingConv(getRuntimeCC()); - // In Windows Itanium environments, try to mark runtime functions - // dllimport. For Mingw and MSVC, don't. We don't really know if the user - // will link their standard library statically or dynamically. Marking - // functions imported when they are not imported can cause linker errors - // and warnings. - if (!Local && getTriple().isWindowsItaniumEnvironment() && - !getCodeGenOpts().LTOVisibilityPublicStd) { + if (!Local && getTriple().isOSBinFormatCOFF() && + !getCodeGenOpts().LTOVisibilityPublicStd && + !getTriple().isWindowsGNUEnvironment()) { const FunctionDecl *FD = GetRuntimeFunctionDecl(Context, Name); if (!FD || FD->hasAttr()) { F->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass); diff --git a/test/CodeGen/ms-symbol-linkage.cpp b/test/CodeGen/ms-symbol-linkage.cpp deleted file mode 100644 index 3674ad0deb..0000000000 --- a/test/CodeGen/ms-symbol-linkage.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// RUN: %clangxx -target aarch64-windows \ -// RUN: -fcxx-exceptions -c -o - %s \ -// RUN: | llvm-objdump -syms - 2>&1 | FileCheck %s - -void foo1() { throw 1; } -// CHECK-LABEL: foo1 -// CHECK-NOT: __imp__CxxThrowException - -void bar(); -void foo2() noexcept(true) { bar(); } -// CHECK-LABEL: foo2 -// CHECK-NOT: __imp___std_terminate - -struct A {}; -struct B { virtual void f(); }; -struct C : A, virtual B {}; -struct T {}; -T *foo3() { return dynamic_cast((C *)0); } -// CHECK-LABEL: foo3 -// CHECK-NOT: __imp___RTDynamicCast diff --git a/test/CodeGenCXX/runtime-dllstorage.cpp b/test/CodeGenCXX/runtime-dllstorage.cpp index 3c0c73f9aa..7220fa50b0 100644 --- a/test/CodeGenCXX/runtime-dllstorage.cpp +++ b/test/CodeGenCXX/runtime-dllstorage.cpp @@ -108,7 +108,7 @@ void l() { // CHECK-MS-DAG: @_Init_thread_epoch = external thread_local global i32 // CHECK-MS-DAG: declare dso_local i32 @__tlregdtor(void ()*) // CHECK-MS-DAG: declare dso_local i32 @atexit(void ()*) -// CHECK-MS-DYNAMIC-DAG: declare {{.*}} void @_CxxThrowException +// CHECK-MS-DYNAMIC-DAG: declare dllimport {{.*}} void @_CxxThrowException // CHECK-MS-STATIC-DAG: declare {{.*}} void @_CxxThrowException // CHECK-MS-DAG: declare dso_local noalias i8* @"??2@YAPAXI@Z" // CHECK-MS-DAG: declare dso_local void @_Init_thread_header(i32*) diff --git a/test/CodeGenObjC/gnu-init.m b/test/CodeGenObjC/gnu-init.m index 6d562b80cb..32db49fdf9 100644 --- a/test/CodeGenObjC/gnu-init.m +++ b/test/CodeGenObjC/gnu-init.m @@ -100,6 +100,6 @@ // Check our load function is in a comdat. // CHECK-WIN: define linkonce_odr hidden void @.objcv2_load_function() comdat { -// Make sure we do not have dllimport on the load function -// CHECK-WIN: declare dso_local void @__objc_load +// Make sure we have dllimport on the load function +// CHECK-WIN: declare dllimport void @__objc_load diff --git a/test/CodeGenObjCXX/msabi-stret.mm b/test/CodeGenObjCXX/msabi-stret.mm index 66e407af27..765c23887b 100644 --- a/test/CodeGenObjCXX/msabi-stret.mm +++ b/test/CodeGenObjCXX/msabi-stret.mm @@ -13,5 +13,6 @@ S f() { return [I m:S()]; } -// CHECK: declare dso_local void @objc_msgSend_stret(i8*, i8*, ...) +// CHECK: declare dllimport void @objc_msgSend_stret(i8*, i8*, ...) // CHECK-NOT: declare dllimport void @objc_msgSend(i8*, i8*, ...) + -- 2.40.0