Skip to content

Commit 2168dcb

Browse files
authored
Clean up and rework DXIL library depencencies (microsoft#4877)
* Clean up and rework DXIL library depencencies This change reworks the dependency specifications for the DXIL* libraries. Many of these libraries had over and under specified dependencies. This also collapses the DxilRDATBuidlder into the DxilContainer library to remove the cyclic dependency between the two libraries. * Break assert dependency between DXIL and Analysis In assert builds the DXILModule constructor was creating forced bindings to debugging methods that are often used from the debugger. This forced binding is useful, but doesn't need to live in the DXIL library. To break the dependency I've moved the code into Analysis. I've also made that code only included when building with MSVC. When using other compilers `__attribute__((used))` can be applied to the function via the `LLVM_DUMP_METHOD` annotation to have the same effect.
1 parent 8f39f4a commit 2168dcb

File tree

24 files changed

+36
-53
lines changed

24 files changed

+36
-53
lines changed

include/dxc/DXIL/DxilModule.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,6 @@ class DxilModule {
354354
bool m_ForceZeroStoreLifetimes = false;
355355

356356
std::unique_ptr<OP> m_pOP;
357-
size_t m_pUnused = 0;
358357

359358
// LLVM used.
360359
std::vector<llvm::GlobalVariable*> m_LLVMUsed;

include/llvm/IR/Function.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,14 +523,15 @@ class Function : public GlobalObject, public ilist_node<Function> {
523523
/// basic block inside. This depends on there being a 'dot' and 'gv' program
524524
/// in your path.
525525
///
526-
void viewCFG() const;
526+
LLVM_DUMP_METHOD void viewCFG() const; // HLSL Change - Add LLVM_DUMP_METHOD
527527

528528
/// viewCFGOnly - This function is meant for use from the debugger. It works
529529
/// just like viewCFG, but it does not include the contents of basic blocks
530530
/// into the nodes, just the label. If you are only interested in the CFG
531531
/// this can make the graph smaller.
532532
///
533-
void viewCFGOnly() const;
533+
// HLSL Change - Add LLVM_DUMP_METHOD
534+
LLVM_DUMP_METHOD void viewCFGOnly() const;
534535

535536
/// Methods for support type inquiry through isa, cast, and dyn_cast:
536537
static inline bool classof(const Value *V) {

include/llvm/IR/Module.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ class Module {
662662
bool ShouldPreserveUseListOrder = false) const;
663663

664664
/// Dump the module to stderr (for debugging).
665-
void dump() const;
665+
LLVM_DUMP_METHOD void dump() const; // HLSL Change - Add LLVM_DUMP_METHOD
666666

667667
/// This function causes all the subinstructions to "let go" of all references
668668
/// that they are maintaining. This allows one to 'delete' a whole class at

include/llvm/IR/Type.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class Type {
119119

120120
public:
121121
void print(raw_ostream &O) const;
122-
void dump() const;
122+
LLVM_DUMP_METHOD void dump() const; // HLSL Change - Add LLVM_DUMP_METHOD
123123

124124
/// getContext - Return the LLVMContext in which this type was uniqued.
125125
LLVMContext &getContext() const { return Context; }

lib/Analysis/Analysis.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,26 @@
1818

1919
using namespace llvm;
2020

21+
// HLSL Change Begin - Windows doesn't support __attribute__((used)) so these methods
22+
// need to be forcibly bound or they could be stripped at build time.
23+
#if defined(_MSC_VER) && (!defined(NDEBUG) || defined(LLVM_ENABLE_DUMP))
24+
#pragma optimize("", off)
25+
void BindDumpMethods() {
26+
// Pin LLVM dump methods.
27+
void (__thiscall Module::*pfnModuleDump)() const = &Module::dump;
28+
(void)pfnModuleDump;
29+
void (__thiscall Type::*pfnTypeDump)() const = &Type::dump;
30+
(void)pfnTypeDump;
31+
void (__thiscall Function::*pfnViewCFGOnly)() const = &Function::viewCFGOnly;
32+
(void)pfnViewCFGOnly;
33+
}
34+
#pragma optimize("", on)
35+
#define HLSL_BIND_DUMP_METHODS BindDumpMethods();
36+
#else
37+
#define HLSL_BIND_DUMP_METHODS
38+
#endif
39+
// HLSL Change End
40+
2141
/// initializeAnalysis - Initialize all passes linked into the Analysis library.
2242
void llvm::initializeAnalysis(PassRegistry &Registry) {
2343
initializeAliasAnalysisAnalysisGroup(Registry);
@@ -69,6 +89,8 @@ void llvm::initializeAnalysis(PassRegistry &Registry) {
6989
initializeTargetTransformInfoWrapperPassPass(Registry);
7090
initializeTypeBasedAliasAnalysisPass(Registry);
7191
initializeScopedNoAliasAAPass(Registry);
92+
93+
HLSL_BIND_DUMP_METHODS // HLSL Change - Force binding dump methods.
7294
}
7395

7496
void LLVMInitializeAnalysis(LLVMPassRegistryRef R) {

lib/Analysis/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ add_llvm_library(LLVMAnalysis
7676
${LLVM_MAIN_INCLUDE_DIR}/llvm/Analysis
7777
)
7878

79-
target_link_libraries(LLVMAnalysis INTERFACE LLVMDXIL) # HLSL Change
8079
add_dependencies(LLVMAnalysis intrinsics_gen)
8180

8281
add_subdirectory(IPA)

lib/Analysis/LLVMBuild.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ subdirectories = IPA
2222
type = Library
2323
name = Analysis
2424
parent = Libraries
25-
required_libraries = Core Support
25+
required_libraries = Core DXIL Support

lib/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ add_subdirectory(DxcSupport) # HLSL Change
2525
add_subdirectory(HLSL) # HLSL Change
2626
add_subdirectory(DXIL) # HLSL Change
2727
add_subdirectory(DxilContainer) # HLSL Change
28-
add_subdirectory(DxilRDATBuilder) # HLSL Change
2928
add_subdirectory(DxilPdbInfo) # HLSL Change
3029
add_subdirectory(DxilPIXPasses) # HLSL Change
3130
if(WIN32) # HLSL Change

lib/DXIL/DxilModule.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,6 @@ DxilModule::DxilModule(Module *pModule)
105105

106106
DXASSERT_NOMSG(m_pModule != nullptr);
107107
SetDxilHook(*m_pModule);
108-
109-
#ifndef NDEBUG
110-
// Pin LLVM dump methods.
111-
void (__thiscall Module::*pfnModuleDump)() const = &Module::dump;
112-
void (__thiscall Type::*pfnTypeDump)() const = &Type::dump;
113-
void (__thiscall Function::*pfnViewCFGOnly)() const = &Function::viewCFGOnly;
114-
m_pUnused = (char *)&pfnModuleDump - (char *)&pfnTypeDump;
115-
m_pUnused -= (size_t)&pfnViewCFGOnly;
116-
#endif
117108
}
118109

119110
DxilModule::~DxilModule() { ClearDxilHook(*m_pModule); }

lib/DXIL/LLVMBuild.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
type = Library
1414
name = DXIL
1515
parent = Libraries
16-
required_libraries = Analysis BitReader Core DxcSupport Support
16+
required_libraries = BitReader Core DxcSupport Support

lib/DxilContainer/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ add_llvm_library(LLVMDxilContainer
55
DxilContainerAssembler.cpp
66
DxilContainerReader.cpp
77
DxcContainerBuilder.cpp
8+
DxilRDATBuilder.cpp
89
DxilRuntimeReflection.cpp
910
RDATDxilSubobjects.cpp
1011

lib/DxilContainer/DxilContainerAssembler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@
3636
#include "dxc/Support/dxcapi.impl.h"
3737
#include <assert.h> // Needed for DxilPipelineStateValidation.h
3838
#include "dxc/DxilContainer/DxilPipelineStateValidation.h"
39+
#include "dxc/DxilContainer/DxilRDATBuilder.h"
3940
#include "dxc/DxilContainer/DxilRuntimeReflection.h"
4041
#include "dxc/DXIL/DxilCounters.h"
41-
#include "dxc/DxilRDATBuilder/DxilRDATBuilder.h"
4242
#include <algorithm>
4343
#include <functional>
4444

lib/DxilRDATBuilder/DxilRDATBuilder.cpp renamed to lib/DxilContainer/DxilRDATBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "dxc/Support/Global.h"
2-
#include "dxc/DxilRDATBuilder/DxilRDATBuilder.h"
2+
#include "dxc/DxilContainer/DxilRDATBuilder.h"
33
#include "dxc/DxilContainer/DxilPipelineStateValidation.h"
44
#include "dxc/Support/FileIOHelper.h"
55

lib/DxilContainer/LLVMBuild.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
type = Library
1414
name = DxilContainer
1515
parent = Libraries
16-
required_libraries = BitReader BitWriter Core DxcSupport IPA Support DXIL DxilRDATBuilder
16+
required_libraries = BitReader BitWriter Core DxcSupport IPA Support DXIL

lib/DxilPIXPasses/LLVMBuild.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
type = Library
1414
name = DxilPIXPasses
1515
parent = Libraries
16-
required_libraries = BitReader Core DxcSupport IPA Support
16+
required_libraries = BitReader Core DxcSupport TransformUtils Support

lib/DxilPdbInfo/LLVMBuild.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
type = Library
1414
name = DxilPdbInfo
1515
parent = Libraries
16-
required_libraries = DxilRDATBuilder Core Support
16+
required_libraries = Core Support DxcSupport DxilContainer
1717

lib/DxilRDATBuilder/CMakeLists.txt

Lines changed: 0 additions & 10 deletions
This file was deleted.

lib/DxilRDATBuilder/LLVMBuild.txt

Lines changed: 0 additions & 16 deletions
This file was deleted.

lib/DxilRootSignature/LLVMBuild.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
type = Library
1414
name = DxilRootSignature
1515
parent = Libraries
16-
required_libraries = BitReader Core DxcSupport IPA Support
16+
required_libraries = BitReader Core DXIL DxilContainer DxcSupport IPA Support

lib/LLVMBuild.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ subdirectories =
4141
HLSL
4242
DXIL
4343
DxilContainer
44-
DxilRDATBuilder
4544
DxilPdbInfo
4645
DxilDia
4746
DxrFallback

unittests/Analysis/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
set(LLVM_LINK_COMPONENTS
2-
DXIL # HLSL Change
32
IPA
43
Analysis
54
AsmParser

unittests/IR/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ set(LLVM_LINK_COMPONENTS
22
Analysis
33
AsmParser
44
Core
5-
DXIL # HLSL Change
65
IPA
76
Support
87
)

0 commit comments

Comments
 (0)