Skip to content

Devsh fixes clang 19 1 1 #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: devshFixes
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ mark_as_advanced(DXC_DISABLE_ALLOCATOR_OVERRIDES)
option(DXC_CODEGEN_EXCEPTIONS_TRAP "An exception in code generation generates a trap, ending the compiler process" OFF)
mark_as_advanced(DXC_CODEGEN_EXCEPTIONS_TRAP)

option(DXC_ENABLE_ETW "Compile with ETW Tracing" ON)
mark_as_advanced(DXC_ENABLE_ETW)

if(DXC_ENABLE_ETW)
add_compile_definitions(DXC_ENABLE_ETW)
endif()

# adjust link option to enable debugging from kernel mode; not compatible with incremental linking
if(NOT CMAKE_VERSION VERSION_LESS "3.13" AND MSVC AND NOT CMAKE_C_COMPILER_ARCHITECTURE_ID STREQUAL "ARM64EC")
add_link_options(/DEBUGTYPE:CV,FIXUP,PDATA /INCREMENTAL:NO)
Expand All @@ -108,7 +115,9 @@ endif()
if(MSVC)
# use new Standard Conforming Preprocessor
# https://learn.microsoft.com/en-us/cpp/preprocessor/preprocessor-experimental-overview?view=msvc-170
add_compile_options(/Zc:preprocessor)
if(NOT CMAKE_C_COMPILER_ID STREQUAL "Clang")
add_compile_options(/Zc:preprocessor)
endif()
endif()

# enable control flow guard
Expand Down
4 changes: 2 additions & 2 deletions include/dxc/Support/dxcapi.use.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class DxcDllSupport {
m_dll = LoadLibraryA(dllName);
if (m_dll == nullptr)
return HRESULT_FROM_WIN32(GetLastError());
m_createFn = (DxcCreateInstanceProc)GetProcAddress(m_dll, fnName);
m_createFn = reinterpret_cast<DxcCreateInstanceProc>(reinterpret_cast<void *>(GetProcAddress(m_dll, fnName)));

if (m_createFn == nullptr) {
HRESULT hr = HRESULT_FROM_WIN32(GetLastError());
Expand Down Expand Up @@ -64,7 +64,7 @@ class DxcDllSupport {
fnName2[s] = '2';
fnName2[s + 1] = '\0';
#ifdef _WIN32
m_createFn2 = (DxcCreateInstance2Proc)GetProcAddress(m_dll, fnName2);
m_createFn2 = reinterpret_cast<DxcCreateInstance2Proc>(reinterpret_cast<void *>(GetProcAddress(m_dll, fnName2)));
#else
m_createFn2 = (DxcCreateInstance2Proc)::dlsym(m_dll, fnName2);
#endif
Expand Down
15 changes: 2 additions & 13 deletions include/dxc/WinAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,19 +198,8 @@
#define OutputDebugStringA(msg) fputs(msg, stderr)
#define OutputDebugFormatA(...) fprintf(stderr, __VA_ARGS__)

// Event Tracing for Windows (ETW) provides application programmers the ability
// to start and stop event tracing sessions, instrument an application to
// provide trace events, and consume trace events.
#define DxcEtw_DXCompilerCreateInstance_Start()
#define DxcEtw_DXCompilerCreateInstance_Stop(hr)
#define DxcEtw_DXCompilerCompile_Start()
#define DxcEtw_DXCompilerCompile_Stop(hr)
#define DxcEtw_DXCompilerDisassemble_Start()
#define DxcEtw_DXCompilerDisassemble_Stop(hr)
#define DxcEtw_DXCompilerPreprocess_Start()
#define DxcEtw_DXCompilerPreprocess_Stop(hr)
#define DxcEtw_DxcValidation_Start()
#define DxcEtw_DxcValidation_Stop(hr)
// I have no idea if I don't break something like INSTALL targets, requires CI tests
#include "WinEtwAdapter.h"

#define UInt32Add UIntAdd
#define Int32ToUInt32 IntToUInt
Expand Down
33 changes: 33 additions & 0 deletions include/dxc/WinEtwAdapter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//===- WinEtwAdapter.h - Windows ETW Adapter, stub -*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_SUPPORT_WIN_ETW_ADAPTER_H
#define LLVM_SUPPORT_WIN_ETW_ADAPTER_H

// Event Tracing for Windows (ETW) provides application programmers the ability
// to start and stop event tracing sessions, instrument an application to
// provide trace events, and consume trace events.
#define EventRegisterMicrosoft_Windows_DXCompiler_API()
#define EventUnregisterMicrosoft_Windows_DXCompiler_API()
#define DxcEtw_DXCompilerCreateInstance_Start()
#define DxcEtw_DXCompilerCreateInstance_Stop(hr)
#define DxcEtw_DXCompilerInitialization_Start()
#define DxcEtw_DXCompilerInitialization_Stop(hr)
#define DxcEtw_DXCompilerShutdown_Start()
#define DxcEtw_DXCompilerShutdown_Stop(hr)
#define DxcEtw_DXCompilerCompile_Start()
#define DxcEtw_DXCompilerCompile_Stop(hr)
#define DxcEtw_DXCompilerDisassemble_Start()
#define DxcEtw_DXCompilerDisassemble_Stop(hr)
#define DxcEtw_DXCompilerPreprocess_Start()
#define DxcEtw_DXCompilerPreprocess_Stop(hr)
#define DxcEtw_DxcValidation_Start()
#define DxcEtw_DxcValidation_Stop(hr)

#endif // LLVM_SUPPORT_WIN_ETW_ADAPTER_H
6 changes: 3 additions & 3 deletions include/llvm/CodeGen/SchedulerRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class RegisterScheduler : public MachinePassRegistryNode {
static MachinePassRegistry Registry;

RegisterScheduler(const char *N, const char *D, FunctionPassCtor C)
: MachinePassRegistryNode(N, D, (MachinePassCtor)C)
: MachinePassRegistryNode(N, D, reinterpret_cast<MachinePassCtor>(reinterpret_cast<void *>(C)))
{ Registry.Add(this); }
~RegisterScheduler() { Registry.Remove(this); }

Expand All @@ -54,10 +54,10 @@ class RegisterScheduler : public MachinePassRegistryNode {
return (RegisterScheduler *)Registry.getList();
}
static FunctionPassCtor getDefault() {
return (FunctionPassCtor)Registry.getDefault();
return reinterpret_cast<FunctionPassCtor>(reinterpret_cast<void *>(Registry.getDefault()));
}
static void setDefault(FunctionPassCtor C) {
Registry.setDefault((MachinePassCtor)C);
Registry.setDefault(reinterpret_cast<MachinePassCtor>(reinterpret_cast<void *>(C)));
}
static void setListener(MachinePassRegistryListener *L) {
Registry.setListener(L);
Expand Down
3 changes: 2 additions & 1 deletion lib/IR/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ void LLVMContextSetDiagnosticHandler(LLVMContextRef C,
LLVMDiagnosticHandler Handler,
void *DiagnosticContext) {
unwrap(C)->setDiagnosticHandler(
LLVM_EXTENSION reinterpret_cast<LLVMContext::DiagnosticHandlerTy>(Handler),
reinterpret_cast<LLVMContext::DiagnosticHandlerTy>(
reinterpret_cast<void *>(Handler)),
DiagnosticContext);
}

Expand Down
5 changes: 3 additions & 2 deletions lib/MSSupport/MSFileSystemImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,9 @@ typedef BOOLEAN(WINAPI *PtrCreateSymbolicLinkW)(
/*__in*/ DWORD dwFlags);

PtrCreateSymbolicLinkW create_symbolic_link_api =
PtrCreateSymbolicLinkW(::GetProcAddress(::GetModuleHandleW(L"Kernel32.dll"),
"CreateSymbolicLinkW"));
PtrCreateSymbolicLinkW(reinterpret_cast<void *>(::GetProcAddress(
::GetModuleHandleW(L"Kernel32.dll"),
"CreateSymbolicLinkW")));
} // namespace
#endif

Expand Down
26 changes: 11 additions & 15 deletions lib/Support/Windows/RWMutex.inc
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,16 @@ static bool loadSRW() {
sChecked = true;

if (HMODULE hLib = ::GetModuleHandleW(L"Kernel32.dll")) {
fpInitializeSRWLock =
(VOID (WINAPI *)(PSRWLOCK))::GetProcAddress(hLib,
"InitializeSRWLock");
fpAcquireSRWLockExclusive =
(VOID (WINAPI *)(PSRWLOCK))::GetProcAddress(hLib,
"AcquireSRWLockExclusive");
fpAcquireSRWLockShared =
(VOID (WINAPI *)(PSRWLOCK))::GetProcAddress(hLib,
"AcquireSRWLockShared");
fpReleaseSRWLockExclusive =
(VOID (WINAPI *)(PSRWLOCK))::GetProcAddress(hLib,
"ReleaseSRWLockExclusive");
fpReleaseSRWLockShared =
(VOID (WINAPI *)(PSRWLOCK))::GetProcAddress(hLib,
"ReleaseSRWLockShared");
fpInitializeSRWLock = reinterpret_cast<VOID (WINAPI *)(PSRWLOCK)>(
reinterpret_cast<void *>(::GetProcAddress(hLib, "InitializeSRWLock")));
fpAcquireSRWLockExclusive = reinterpret_cast<VOID (WINAPI *)(PSRWLOCK)>(
reinterpret_cast<void *>(::GetProcAddress(hLib, "AcquireSRWLockExclusive")));
fpAcquireSRWLockShared = reinterpret_cast<VOID (WINAPI *)(PSRWLOCK)>(
reinterpret_cast<void *>(::GetProcAddress(hLib, "AcquireSRWLockShared")));
fpReleaseSRWLockExclusive = reinterpret_cast<VOID (WINAPI *)(PSRWLOCK)>(
reinterpret_cast<void *>(::GetProcAddress(hLib, "ReleaseSRWLockExclusive")));
fpReleaseSRWLockShared = reinterpret_cast<VOID (WINAPI *)(PSRWLOCK)>(
reinterpret_cast<void *>(::GetProcAddress(hLib, "ReleaseSRWLockShared")));

if (fpInitializeSRWLock != NULL) {
sHasSRW = true;
Expand All @@ -73,6 +68,7 @@ static bool loadSRW() {
return sHasSRW;
}


RWMutexImpl::RWMutexImpl() {
// TODO: harden to allocation failures - HLSL Change
if (loadSRW()) {
Expand Down
4 changes: 4 additions & 0 deletions projects/dxilconv/tools/dxilconv/dxilconv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@
#include "dxc/config.h"
#include "dxc/dxcisense.h"
#include "dxc/dxctools.h"
#ifdef DXC_ENABLE_ETW
#include "dxcetw.h"
#else
#include "dxc/WinEtwAdapter.h"
#endif // DXC_ENABLE_ETW

#include "DxbcConverter.h"

Expand Down
3 changes: 2 additions & 1 deletion tools/clang/tools/dxcompiler/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ endif (MSVC)

add_clang_library(dxcompiler SHARED ${SOURCES})
add_dependencies(dxcompiler TablegenHLSLOptions)
if (MSVC)

if (MSVC AND DXC_ENABLE_ETW)
# No DxcEtw on non-Windows platforms.
add_dependencies(dxcompiler DxcEtw)
endif()
Expand Down
4 changes: 4 additions & 0 deletions tools/clang/tools/dxcompiler/DXCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/ManagedStatic.h"
#ifdef LLVM_ON_WIN32
#ifdef DXC_ENABLE_ETW
#include "dxcetw.h"
#else
#include "dxc/WinEtwAdapter.h"
#endif // DXC_ENABLE_ETW
#endif
#include "dxillib.h"

Expand Down
2 changes: 2 additions & 0 deletions tools/clang/tools/dxcompiler/DXCompiler.rc
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@
#define VER_ORIGINALFILENAME_STR "DXCompiler.dll"

// #include <common.ver>
#ifdef DXC_ENABLE_ETW
#include "dxcetw.rc"
#endif
4 changes: 4 additions & 0 deletions tools/clang/tools/dxcompiler/dxcapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@
#include "dxc/dxcisense.h"
#include "dxc/dxctools.h"
#ifdef _WIN32
#ifdef DXC_ENABLE_ETW
#include "dxcetw.h"
#else
#include "dxc/WinEtwAdapter.h"
#endif // DXC_ENABLE_ETW
#endif
#include "dxc/DxilContainer/DxcContainerBuilder.h"
#include "dxillib.h"
Expand Down
4 changes: 4 additions & 0 deletions tools/clang/tools/dxcompiler/dxcompilerobj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@
#include "dxc/Support/microcom.h"

#ifdef _WIN32
#ifdef DXC_ENABLE_ETW
#include "dxcetw.h"
#else
#include "dxc/WinEtwAdapter.h"
#endif // DXC_ENABLE_ETW
#endif
#include "dxcompileradapter.h"
#include "dxcshadersourceinfo.h"
Expand Down
4 changes: 4 additions & 0 deletions tools/clang/tools/dxcvalidator/dxcvalidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@
#include "dxc/Support/dxcapi.impl.h"

#ifdef _WIN32
#ifdef DXC_ENABLE_ETW
#include "dxcetw.h"
#else
#include "dxc/WinEtwAdapter.h"
#endif // DXC_ENABLE_ETW
#endif

using namespace llvm;
Expand Down
4 changes: 4 additions & 0 deletions tools/clang/tools/dxildll/dxildll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@
#include "llvm/Support/ManagedStatic.h"
#include <algorithm>
#ifdef _WIN32
#ifdef DXC_ENABLE_ETW
#include "Tracing/DxcRuntimeEtw.h"
#include "dxc/Tracing/dxcetw.h"
#else
#include "dxc/WinEtwAdapter.h"
#endif // DXC_ENABLE_ETW
#endif

#include "dxc/dxcisense.h"
Expand Down
4 changes: 4 additions & 0 deletions tools/clang/tools/dxrfallbackcompiler/DXCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
#include "dxc/Support/Global.h"
#include "dxc/Support/HLSLOptions.h"
#include "dxc/config.h"
#ifdef DXC_ENABLE_ETW
#include "dxcetw.h"
#else
#include "dxc/WinEtwAdapter.h"
#endif // DXC_ENABLE_ETW
#include "dxillib.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/ManagedStatic.h"
Expand Down
2 changes: 2 additions & 0 deletions tools/clang/tools/dxrfallbackcompiler/DXCompiler.rc
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@
#define VER_ORIGINALFILENAME_STR "DxrFallbackCompiler.dll"

// #include <common.ver>
#ifdef DXC_ENABLE_ETW
#include "dxcetw.rc"
#endif
4 changes: 4 additions & 0 deletions tools/clang/tools/dxrfallbackcompiler/dxcapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
#include "dxc/Support/Global.h"
#include "dxc/dxcdxrfallbackcompiler.h"
#include "dxc/dxctools.h"
#ifdef DXC_ENABLE_ETW
#include "dxcetw.h"
#else
#include "dxc/WinEtwAdapter.h"
#endif // DXC_ENABLE_ETW
#include <memory>

HRESULT CreateDxcDxrFallbackCompiler(REFIID riid, LPVOID *ppv);
Expand Down
Loading