aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2023-08-15 17:34:26 -0700
committerJustin Bogner <mail@justinbogner.com>2023-08-16 13:12:32 -0700
commit72017fcf00b33b99aac604355d260910b1d57dfc (patch)
treede955ccb6c42b1ba812afaba2bad03cac8ee4902 /llvm/lib/Target/DirectX/DirectXTargetMachine.cpp
parent939bdaec18c9f22ac52809fea5a1ab0301a90f02 (diff)
downloadllvm-72017fcf00b33b99aac604355d260910b1d57dfc.zip
llvm-72017fcf00b33b99aac604355d260910b1d57dfc.tar.gz
llvm-72017fcf00b33b99aac604355d260910b1d57dfc.tar.bz2
[DirectX] Only embed dxil when writing object files
When emitting assembly we don't particularly want the binary DXIL embedded in the output. This was mostly there for testing purposes, so we update those tests to run the test directly using `opt` and restrict the -dxil-embed and -dxil-globals passes to running normally only in the case where we're trying to emit a DXContainer. Differential Revision: https://reviews.llvm.org/D158051
Diffstat (limited to 'llvm/lib/Target/DirectX/DirectXTargetMachine.cpp')
-rw-r--r--llvm/lib/Target/DirectX/DirectXTargetMachine.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp b/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp
index 59e6fcb..1111bb8 100644
--- a/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp
+++ b/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp
@@ -42,6 +42,7 @@ extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeDirectXTarget() {
initializeDXILPrepareModulePass(*PR);
initializeEmbedDXILPassPass(*PR);
initializeWriteDXILPassPass(*PR);
+ initializeDXContainerGlobalsPass(*PR);
initializeDXILOpLoweringLegacyPass(*PR);
initializeDXILTranslateMetadataPass(*PR);
initializeDXILResourceWrapperPass(*PR);
@@ -127,12 +128,6 @@ bool DirectXTargetMachine::addPassesToEmitFile(
TargetPassConfig *PassConfig = createPassConfig(PM);
PassConfig->addCodeGenPrepare();
- if (TargetPassConfig::willCompleteCodeGenPipeline()) {
- PM.add(createDXILEmbedderPass());
- // We embed the other DXContainer globals after embedding DXIL so that the
- // globals don't pollute the DXIL.
- PM.add(createDXContainerGlobalsPass());
- }
switch (FileType) {
case CGFT_AssemblyFile:
PM.add(createDXILPrettyPrinterPass(Out));
@@ -140,6 +135,11 @@ bool DirectXTargetMachine::addPassesToEmitFile(
break;
case CGFT_ObjectFile:
if (TargetPassConfig::willCompleteCodeGenPipeline()) {
+ PM.add(createDXILEmbedderPass());
+ // We embed the other DXContainer globals after embedding DXIL so that the
+ // globals don't pollute the DXIL.
+ PM.add(createDXContainerGlobalsPass());
+
if (!MMIWP)
MMIWP = new MachineModuleInfoWrapperPass(this);
PM.add(MMIWP);