Skip to content

Commit 94f9609

Browse files
committed
Revert 10f3296 - [openmp] Fix warnings when building on Windows with latest MSVC or Clang ToT (#77853)
It broke the AMDGPU buildbot: https://lab.llvm.org/buildbot/#/builders/193/builds/45378
1 parent 16df714 commit 94f9609

File tree

8 files changed

+34
-60
lines changed

8 files changed

+34
-60
lines changed

openmp/cmake/HandleOpenMPOptions.cmake

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,3 @@ append_if(OPENMP_HAVE_WMAYBE_UNINITIALIZED_FLAG "-Wno-maybe-uninitialized" CMAKE
4141
append_if(OPENMP_HAVE_NO_SEMANTIC_INTERPOSITION "-fno-semantic-interposition" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
4242
append_if(OPENMP_HAVE_FUNCTION_SECTIONS "-ffunction-section" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
4343
append_if(OPENMP_HAVE_DATA_SECTIONS "-fdata-sections" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
44-
45-
if (MSVC)
46-
# Disable "warning C4201: nonstandard extension used: nameless struct/union"
47-
append("-wd4201" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
48-
49-
# Disable "warning C4190: '__kmpc_atomic_cmplx8_rd' has C-linkage specified, but returns
50-
# UDT '__kmp_cmplx64_t' which is incompatible with C"
51-
append("-wd4190" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
52-
endif()

openmp/runtime/src/kmp_affinity.cpp

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
#endif
2929
#include <ctype.h>
3030

31-
#include "llvm/Support/Compiler.h"
32-
3331
// The machine topology
3432
kmp_topology_t *__kmp_topology = nullptr;
3533
// KMP_HW_SUBSET environment variable
@@ -129,12 +127,8 @@ const char *__kmp_hw_get_catalog_string(kmp_hw_t type, bool plural) {
129127
return ((plural) ? KMP_I18N_STR(Threads) : KMP_I18N_STR(Thread));
130128
case KMP_HW_PROC_GROUP:
131129
return ((plural) ? KMP_I18N_STR(ProcGroups) : KMP_I18N_STR(ProcGroup));
132-
case KMP_HW_UNKNOWN:
133-
case KMP_HW_LAST:
134-
return KMP_I18N_STR(Unknown);
135130
}
136-
KMP_ASSERT2(false, "Unhandled kmp_hw_t enumeration");
137-
LLVM_BUILTIN_UNREACHABLE;
131+
return KMP_I18N_STR(Unknown);
138132
}
139133

140134
const char *__kmp_hw_get_keyword(kmp_hw_t type, bool plural) {
@@ -163,18 +157,13 @@ const char *__kmp_hw_get_keyword(kmp_hw_t type, bool plural) {
163157
return ((plural) ? "threads" : "thread");
164158
case KMP_HW_PROC_GROUP:
165159
return ((plural) ? "proc_groups" : "proc_group");
166-
case KMP_HW_UNKNOWN:
167-
case KMP_HW_LAST:
168-
return ((plural) ? "unknowns" : "unknown");
169160
}
170-
KMP_ASSERT2(false, "Unhandled kmp_hw_t enumeration");
171-
LLVM_BUILTIN_UNREACHABLE;
161+
return ((plural) ? "unknowns" : "unknown");
172162
}
173163

174164
const char *__kmp_hw_get_core_type_string(kmp_hw_core_type_t type) {
175165
switch (type) {
176166
case KMP_HW_CORE_TYPE_UNKNOWN:
177-
case KMP_HW_MAX_NUM_CORE_TYPES:
178167
return "unknown";
179168
#if KMP_ARCH_X86 || KMP_ARCH_X86_64
180169
case KMP_HW_CORE_TYPE_ATOM:
@@ -183,8 +172,7 @@ const char *__kmp_hw_get_core_type_string(kmp_hw_core_type_t type) {
183172
return "Intel(R) Core(TM) processor";
184173
#endif
185174
}
186-
KMP_ASSERT2(false, "Unhandled kmp_hw_core_type_t enumeration");
187-
LLVM_BUILTIN_UNREACHABLE;
175+
return "unknown";
188176
}
189177

190178
#if KMP_AFFINITY_SUPPORTED
@@ -1250,18 +1238,17 @@ bool kmp_topology_t::filter_hw_subset() {
12501238
struct core_type_indexer {
12511239
int operator()(const kmp_hw_thread_t &t) const {
12521240
switch (t.attrs.get_core_type()) {
1253-
case KMP_HW_CORE_TYPE_UNKNOWN:
1254-
case KMP_HW_MAX_NUM_CORE_TYPES:
1255-
return 0;
12561241
#if KMP_ARCH_X86 || KMP_ARCH_X86_64
12571242
case KMP_HW_CORE_TYPE_ATOM:
12581243
return 1;
12591244
case KMP_HW_CORE_TYPE_CORE:
12601245
return 2;
12611246
#endif
1247+
case KMP_HW_CORE_TYPE_UNKNOWN:
1248+
return 0;
12621249
}
1263-
KMP_ASSERT2(false, "Unhandled kmp_hw_thread_t enumeration");
1264-
LLVM_BUILTIN_UNREACHABLE;
1250+
KMP_ASSERT(0);
1251+
return 0;
12651252
}
12661253
};
12671254
struct core_eff_indexer {

openmp/runtime/src/kmp_barrier.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2403,11 +2403,11 @@ void __kmp_fork_barrier(int gtid, int tid) {
24032403
#if USE_ITT_BUILD
24042404
void *itt_sync_obj = NULL;
24052405
#endif /* USE_ITT_BUILD */
2406-
#ifdef KMP_DEBUG
24072406
if (team)
2408-
KA_TRACE(10, ("__kmp_fork_barrier: T#%d(%d:%d) has arrived\n", gtid,
2409-
(team != NULL) ? team->t.t_id : -1, tid));
2410-
#endif
2407+
2408+
KA_TRACE(10, ("__kmp_fork_barrier: T#%d(%d:%d) has arrived\n", gtid,
2409+
(team != NULL) ? team->t.t_id : -1, tid));
2410+
24112411
// th_team pointer only valid for primary thread here
24122412
if (KMP_MASTER_TID(tid)) {
24132413
#if USE_ITT_BUILD && USE_ITT_NOTIFY

openmp/runtime/src/kmp_io.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,24 @@ static HANDLE __kmp_stderr = NULL;
5050
static int __kmp_console_exists = FALSE;
5151
static kmp_str_buf_t __kmp_console_buf;
5252

53+
static int is_console(void) {
54+
char buffer[128];
55+
DWORD rc = 0;
56+
DWORD err = 0;
57+
// Try to get console title.
58+
SetLastError(0);
59+
// GetConsoleTitle does not reset last error in case of success or short
60+
// buffer, so we need to clear it explicitly.
61+
rc = GetConsoleTitle(buffer, sizeof(buffer));
62+
if (rc == 0) {
63+
// rc == 0 means getting console title failed. Let us find out why.
64+
err = GetLastError();
65+
// err == 0 means buffer too short (we suppose console exists).
66+
// In Window applications we usually have err == 6 (invalid handle).
67+
}
68+
return rc > 0 || err == 0;
69+
}
70+
5371
void __kmp_close_console(void) {
5472
/* wait until user presses return before closing window */
5573
/* TODO only close if a window was opened */
@@ -66,6 +84,7 @@ void __kmp_close_console(void) {
6684
static void __kmp_redirect_output(void) {
6785
__kmp_acquire_bootstrap_lock(&__kmp_console_lock);
6886

87+
(void)is_console;
6988
if (!__kmp_console_exists) {
7089
HANDLE ho;
7190
HANDLE he;

openmp/runtime/src/kmp_os.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,6 @@ template <> struct traits_t<unsigned long long> {
306306
!KMP_MIC)
307307

308308
#if KMP_OS_WINDOWS
309-
// Don't include everything related to NT status code, we'll do that explicitly
310-
#define WIN32_NO_STATUS
311309
#include <windows.h>
312310

313311
static inline int KMP_GET_PAGE_SIZE(void) {

openmp/runtime/src/kmp_settings.cpp

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
#include "ompd-specific.h"
3030
#endif
3131

32-
#include "llvm/Support/Compiler.h"
33-
3432
static int __kmp_env_toPrint(char const *name, int flag);
3533

3634
bool __kmp_env_format = 0; // 0 - old format; 1 - new format
@@ -875,10 +873,6 @@ static void __kmp_stg_print_wait_policy(kmp_str_buf_t *buffer, char const *name,
875873
case library_throughput: {
876874
value = "PASSIVE";
877875
} break;
878-
case library_none:
879-
case library_serial: {
880-
value = NULL;
881-
} break;
882876
}
883877
} else {
884878
switch (__kmp_library) {
@@ -891,9 +885,6 @@ static void __kmp_stg_print_wait_policy(kmp_str_buf_t *buffer, char const *name,
891885
case library_throughput: {
892886
value = "throughput";
893887
} break;
894-
case library_none: {
895-
value = NULL;
896-
} break;
897888
}
898889
}
899890
if (value != NULL) {
@@ -2013,7 +2004,6 @@ static inline const char *
20132004
__kmp_hw_get_core_type_keyword(kmp_hw_core_type_t type) {
20142005
switch (type) {
20152006
case KMP_HW_CORE_TYPE_UNKNOWN:
2016-
case KMP_HW_MAX_NUM_CORE_TYPES:
20172007
return "unknown";
20182008
#if KMP_ARCH_X86 || KMP_ARCH_X86_64
20192009
case KMP_HW_CORE_TYPE_ATOM:
@@ -2022,8 +2012,7 @@ __kmp_hw_get_core_type_keyword(kmp_hw_core_type_t type) {
20222012
return "intel_core";
20232013
#endif
20242014
}
2025-
KMP_ASSERT2(false, "Unhandled kmp_hw_core_type_t enumeration");
2026-
LLVM_BUILTIN_UNREACHABLE;
2015+
return "unknown";
20272016
}
20282017

20292018
#if KMP_AFFINITY_SUPPORTED
@@ -4439,10 +4428,6 @@ static void __kmp_stg_print_omp_schedule(kmp_str_buf_t *buffer,
44394428
case kmp_sch_auto:
44404429
__kmp_str_buf_print(buffer, "%s,%d'\n", "auto", __kmp_chunk);
44414430
break;
4442-
default:
4443-
KMP_ASSERT2(false, "Unhandled sched_type enumeration");
4444-
LLVM_BUILTIN_UNREACHABLE;
4445-
break;
44464431
}
44474432
} else {
44484433
switch (sched) {
@@ -4468,10 +4453,6 @@ static void __kmp_stg_print_omp_schedule(kmp_str_buf_t *buffer,
44684453
case kmp_sch_auto:
44694454
__kmp_str_buf_print(buffer, "%s'\n", "auto");
44704455
break;
4471-
default:
4472-
KMP_ASSERT2(false, "Unhandled sched_type enumeration");
4473-
LLVM_BUILTIN_UNREACHABLE;
4474-
break;
44754456
}
44764457
}
44774458
} // __kmp_stg_print_omp_schedule

openmp/runtime/src/kmp_wait_release.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
#include "ompt-specific.h"
2121
#endif
2222

23-
#include "llvm/Support/Compiler.h"
24-
2523
/*!
2624
@defgroup WAIT_RELEASE Wait/Release operations
2725
@@ -1040,14 +1038,15 @@ static inline void __kmp_null_resume_wrapper(kmp_info_t *thr) {
10401038
case flag_oncore:
10411039
__kmp_resume_oncore(gtid, RCAST(kmp_flag_oncore *, flag));
10421040
break;
1041+
#ifdef KMP_DEBUG
10431042
case flag_unset:
10441043
KF_TRACE(100, ("__kmp_null_resume_wrapper: flag type %d is unset\n", type));
10451044
break;
10461045
default:
10471046
KF_TRACE(100, ("__kmp_null_resume_wrapper: flag type %d does not match any "
10481047
"known flag type\n",
10491048
type));
1050-
LLVM_BUILTIN_UNREACHABLE;
1049+
#endif
10511050
}
10521051
}
10531052

openmp/runtime/src/z_Windows_NT_util.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
number of running threads in the system. */
2323

2424
#include <ntsecapi.h> // UNICODE_STRING
25-
#undef WIN32_NO_STATUS
2625
#include <ntstatus.h>
2726
#include <psapi.h>
2827
#ifdef _MSC_VER
@@ -1636,7 +1635,7 @@ int __kmp_get_load_balance(int max) {
16361635
// threads on all cores. So, we don't consider the running threads of this
16371636
// process.
16381637
if (pid != 0) {
1639-
for (ULONG i = 0; i < num; ++i) {
1638+
for (int i = 0; i < num; ++i) {
16401639
THREAD_STATE state = spi->Threads[i].State;
16411640
// Count threads that have Ready or Running state.
16421641
// !!! TODO: Why comment does not match the code???

0 commit comments

Comments
 (0)