Skip to content

Commit 71f2766

Browse files
authored
Merge pull request #7 from Devsh-Graphics-Programming/devshFixes_clang_19_1_1
Devsh fixes clang 19 1 1
2 parents 5ab4d36 + 2661dd0 commit 71f2766

File tree

19 files changed

+104
-38
lines changed

19 files changed

+104
-38
lines changed

CMakeLists.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,13 @@ mark_as_advanced(DXC_DISABLE_ALLOCATOR_OVERRIDES)
100100
option(DXC_CODEGEN_EXCEPTIONS_TRAP "An exception in code generation generates a trap, ending the compiler process" OFF)
101101
mark_as_advanced(DXC_CODEGEN_EXCEPTIONS_TRAP)
102102

103+
option(DXC_ENABLE_ETW "Compile with ETW Tracing" ON)
104+
mark_as_advanced(DXC_ENABLE_ETW)
105+
106+
if(DXC_ENABLE_ETW)
107+
add_compile_definitions(DXC_ENABLE_ETW)
108+
endif()
109+
103110
# adjust link option to enable debugging from kernel mode; not compatible with incremental linking
104111
if(NOT CMAKE_VERSION VERSION_LESS "3.13" AND MSVC AND NOT CMAKE_C_COMPILER_ARCHITECTURE_ID STREQUAL "ARM64EC")
105112
add_link_options(/DEBUGTYPE:CV,FIXUP,PDATA /INCREMENTAL:NO)
@@ -108,7 +115,9 @@ endif()
108115
if(MSVC)
109116
# use new Standard Conforming Preprocessor
110117
# https://learn.microsoft.com/en-us/cpp/preprocessor/preprocessor-experimental-overview?view=msvc-170
111-
add_compile_options(/Zc:preprocessor)
118+
if(NOT CMAKE_C_COMPILER_ID STREQUAL "Clang")
119+
add_compile_options(/Zc:preprocessor)
120+
endif()
112121
endif()
113122

114123
# enable control flow guard

include/dxc/Support/dxcapi.use.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class DxcDllSupport {
3434
m_dll = LoadLibraryA(dllName);
3535
if (m_dll == nullptr)
3636
return HRESULT_FROM_WIN32(GetLastError());
37-
m_createFn = (DxcCreateInstanceProc)GetProcAddress(m_dll, fnName);
37+
m_createFn = reinterpret_cast<DxcCreateInstanceProc>(reinterpret_cast<void *>(GetProcAddress(m_dll, fnName)));
3838

3939
if (m_createFn == nullptr) {
4040
HRESULT hr = HRESULT_FROM_WIN32(GetLastError());
@@ -64,7 +64,7 @@ class DxcDllSupport {
6464
fnName2[s] = '2';
6565
fnName2[s + 1] = '\0';
6666
#ifdef _WIN32
67-
m_createFn2 = (DxcCreateInstance2Proc)GetProcAddress(m_dll, fnName2);
67+
m_createFn2 = reinterpret_cast<DxcCreateInstance2Proc>(reinterpret_cast<void *>(GetProcAddress(m_dll, fnName2)));
6868
#else
6969
m_createFn2 = (DxcCreateInstance2Proc)::dlsym(m_dll, fnName2);
7070
#endif

include/dxc/WinAdapter.h

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -198,19 +198,8 @@
198198
#define OutputDebugStringA(msg) fputs(msg, stderr)
199199
#define OutputDebugFormatA(...) fprintf(stderr, __VA_ARGS__)
200200

201-
// Event Tracing for Windows (ETW) provides application programmers the ability
202-
// to start and stop event tracing sessions, instrument an application to
203-
// provide trace events, and consume trace events.
204-
#define DxcEtw_DXCompilerCreateInstance_Start()
205-
#define DxcEtw_DXCompilerCreateInstance_Stop(hr)
206-
#define DxcEtw_DXCompilerCompile_Start()
207-
#define DxcEtw_DXCompilerCompile_Stop(hr)
208-
#define DxcEtw_DXCompilerDisassemble_Start()
209-
#define DxcEtw_DXCompilerDisassemble_Stop(hr)
210-
#define DxcEtw_DXCompilerPreprocess_Start()
211-
#define DxcEtw_DXCompilerPreprocess_Stop(hr)
212-
#define DxcEtw_DxcValidation_Start()
213-
#define DxcEtw_DxcValidation_Stop(hr)
201+
// I have no idea if I don't break something like INSTALL targets, requires CI tests
202+
#include "WinEtwAdapter.h"
214203

215204
#define UInt32Add UIntAdd
216205
#define Int32ToUInt32 IntToUInt

include/dxc/WinEtwAdapter.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//===- WinEtwAdapter.h - Windows ETW Adapter, stub -*- C++ -*-===//
2+
//
3+
// The LLVM Compiler Infrastructure
4+
//
5+
// This file is distributed under the University of Illinois Open Source
6+
// License. See LICENSE.TXT for details.
7+
//
8+
//===----------------------------------------------------------------------===//
9+
10+
#ifndef LLVM_SUPPORT_WIN_ETW_ADAPTER_H
11+
#define LLVM_SUPPORT_WIN_ETW_ADAPTER_H
12+
13+
// Event Tracing for Windows (ETW) provides application programmers the ability
14+
// to start and stop event tracing sessions, instrument an application to
15+
// provide trace events, and consume trace events.
16+
#define EventRegisterMicrosoft_Windows_DXCompiler_API()
17+
#define EventUnregisterMicrosoft_Windows_DXCompiler_API()
18+
#define DxcEtw_DXCompilerCreateInstance_Start()
19+
#define DxcEtw_DXCompilerCreateInstance_Stop(hr)
20+
#define DxcEtw_DXCompilerInitialization_Start()
21+
#define DxcEtw_DXCompilerInitialization_Stop(hr)
22+
#define DxcEtw_DXCompilerShutdown_Start()
23+
#define DxcEtw_DXCompilerShutdown_Stop(hr)
24+
#define DxcEtw_DXCompilerCompile_Start()
25+
#define DxcEtw_DXCompilerCompile_Stop(hr)
26+
#define DxcEtw_DXCompilerDisassemble_Start()
27+
#define DxcEtw_DXCompilerDisassemble_Stop(hr)
28+
#define DxcEtw_DXCompilerPreprocess_Start()
29+
#define DxcEtw_DXCompilerPreprocess_Stop(hr)
30+
#define DxcEtw_DxcValidation_Start()
31+
#define DxcEtw_DxcValidation_Stop(hr)
32+
33+
#endif // LLVM_SUPPORT_WIN_ETW_ADAPTER_H

include/llvm/CodeGen/SchedulerRegistry.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class RegisterScheduler : public MachinePassRegistryNode {
4040
static MachinePassRegistry Registry;
4141

4242
RegisterScheduler(const char *N, const char *D, FunctionPassCtor C)
43-
: MachinePassRegistryNode(N, D, (MachinePassCtor)C)
43+
: MachinePassRegistryNode(N, D, reinterpret_cast<MachinePassCtor>(reinterpret_cast<void *>(C)))
4444
{ Registry.Add(this); }
4545
~RegisterScheduler() { Registry.Remove(this); }
4646

@@ -54,10 +54,10 @@ class RegisterScheduler : public MachinePassRegistryNode {
5454
return (RegisterScheduler *)Registry.getList();
5555
}
5656
static FunctionPassCtor getDefault() {
57-
return (FunctionPassCtor)Registry.getDefault();
57+
return reinterpret_cast<FunctionPassCtor>(reinterpret_cast<void *>(Registry.getDefault()));
5858
}
5959
static void setDefault(FunctionPassCtor C) {
60-
Registry.setDefault((MachinePassCtor)C);
60+
Registry.setDefault(reinterpret_cast<MachinePassCtor>(reinterpret_cast<void *>(C)));
6161
}
6262
static void setListener(MachinePassRegistryListener *L) {
6363
Registry.setListener(L);

lib/IR/Core.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ void LLVMContextSetDiagnosticHandler(LLVMContextRef C,
9090
LLVMDiagnosticHandler Handler,
9191
void *DiagnosticContext) {
9292
unwrap(C)->setDiagnosticHandler(
93-
LLVM_EXTENSION reinterpret_cast<LLVMContext::DiagnosticHandlerTy>(Handler),
93+
reinterpret_cast<LLVMContext::DiagnosticHandlerTy>(
94+
reinterpret_cast<void *>(Handler)),
9495
DiagnosticContext);
9596
}
9697

lib/MSSupport/MSFileSystemImpl.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,9 @@ typedef BOOLEAN(WINAPI *PtrCreateSymbolicLinkW)(
322322
/*__in*/ DWORD dwFlags);
323323

324324
PtrCreateSymbolicLinkW create_symbolic_link_api =
325-
PtrCreateSymbolicLinkW(::GetProcAddress(::GetModuleHandleW(L"Kernel32.dll"),
326-
"CreateSymbolicLinkW"));
325+
PtrCreateSymbolicLinkW(reinterpret_cast<void *>(::GetProcAddress(
326+
::GetModuleHandleW(L"Kernel32.dll"),
327+
"CreateSymbolicLinkW")));
327328
} // namespace
328329
#endif
329330

lib/Support/Windows/RWMutex.inc

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,16 @@ static bool loadSRW() {
4949
sChecked = true;
5050

5151
if (HMODULE hLib = ::GetModuleHandleW(L"Kernel32.dll")) {
52-
fpInitializeSRWLock =
53-
(VOID (WINAPI *)(PSRWLOCK))::GetProcAddress(hLib,
54-
"InitializeSRWLock");
55-
fpAcquireSRWLockExclusive =
56-
(VOID (WINAPI *)(PSRWLOCK))::GetProcAddress(hLib,
57-
"AcquireSRWLockExclusive");
58-
fpAcquireSRWLockShared =
59-
(VOID (WINAPI *)(PSRWLOCK))::GetProcAddress(hLib,
60-
"AcquireSRWLockShared");
61-
fpReleaseSRWLockExclusive =
62-
(VOID (WINAPI *)(PSRWLOCK))::GetProcAddress(hLib,
63-
"ReleaseSRWLockExclusive");
64-
fpReleaseSRWLockShared =
65-
(VOID (WINAPI *)(PSRWLOCK))::GetProcAddress(hLib,
66-
"ReleaseSRWLockShared");
52+
fpInitializeSRWLock = reinterpret_cast<VOID (WINAPI *)(PSRWLOCK)>(
53+
reinterpret_cast<void *>(::GetProcAddress(hLib, "InitializeSRWLock")));
54+
fpAcquireSRWLockExclusive = reinterpret_cast<VOID (WINAPI *)(PSRWLOCK)>(
55+
reinterpret_cast<void *>(::GetProcAddress(hLib, "AcquireSRWLockExclusive")));
56+
fpAcquireSRWLockShared = reinterpret_cast<VOID (WINAPI *)(PSRWLOCK)>(
57+
reinterpret_cast<void *>(::GetProcAddress(hLib, "AcquireSRWLockShared")));
58+
fpReleaseSRWLockExclusive = reinterpret_cast<VOID (WINAPI *)(PSRWLOCK)>(
59+
reinterpret_cast<void *>(::GetProcAddress(hLib, "ReleaseSRWLockExclusive")));
60+
fpReleaseSRWLockShared = reinterpret_cast<VOID (WINAPI *)(PSRWLOCK)>(
61+
reinterpret_cast<void *>(::GetProcAddress(hLib, "ReleaseSRWLockShared")));
6762

6863
if (fpInitializeSRWLock != NULL) {
6964
sHasSRW = true;
@@ -73,6 +68,7 @@ static bool loadSRW() {
7368
return sHasSRW;
7469
}
7570

71+
7672
RWMutexImpl::RWMutexImpl() {
7773
// TODO: harden to allocation failures - HLSL Change
7874
if (loadSRW()) {

projects/dxilconv/tools/dxilconv/dxilconv.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@
2323
#include "dxc/config.h"
2424
#include "dxc/dxcisense.h"
2525
#include "dxc/dxctools.h"
26+
#ifdef DXC_ENABLE_ETW
2627
#include "dxcetw.h"
28+
#else
29+
#include "dxc/WinEtwAdapter.h"
30+
#endif // DXC_ENABLE_ETW
2731

2832
#include "DxbcConverter.h"
2933

tools/clang/tools/dxcompiler/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ endif (MSVC)
128128

129129
add_clang_library(dxcompiler SHARED ${SOURCES})
130130
add_dependencies(dxcompiler TablegenHLSLOptions)
131-
if (MSVC)
131+
132+
if (MSVC AND DXC_ENABLE_ETW)
132133
# No DxcEtw on non-Windows platforms.
133134
add_dependencies(dxcompiler DxcEtw)
134135
endif()

0 commit comments

Comments
 (0)