[PATCH] D158051: [DirectX] Only embed dxil when writing object files

Justin Bogner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 15 22:07:58 PDT 2023


bogner created this revision.
bogner added a reviewer: beanz.
Herald added subscribers: hiraditya, mcrosier.
Herald added a project: All.
bogner requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158051

Files:
  llvm/lib/Target/DirectX/DirectXTargetMachine.cpp
  llvm/test/CodeGen/DirectX/ContainerData/DebugShaderHash.ll
  llvm/test/CodeGen/DirectX/ContainerData/ShaderHash.ll
  llvm/test/CodeGen/DirectX/embed-dxil.ll


Index: llvm/test/CodeGen/DirectX/embed-dxil.ll
===================================================================
--- llvm/test/CodeGen/DirectX/embed-dxil.ll
+++ llvm/test/CodeGen/DirectX/embed-dxil.ll
@@ -1,4 +1,3 @@
-; RUN: llc %s --filetype=asm -o - | FileCheck %s
 ; RUN: opt %s -dxil-embed -S -o - | FileCheck %s
 ; RUN: llc %s --filetype=obj -o - | obj2yaml | FileCheck %s --check-prefix=DXC
 target triple = "dxil-unknown-shadermodel6.5-library"
Index: llvm/test/CodeGen/DirectX/ContainerData/ShaderHash.ll
===================================================================
--- llvm/test/CodeGen/DirectX/ContainerData/ShaderHash.ll
+++ llvm/test/CodeGen/DirectX/ContainerData/ShaderHash.ll
@@ -1,4 +1,4 @@
-; RUN: llc %s --filetype=asm -o - | FileCheck %s
+; RUN: opt %s -dxil-embed -dxil-globals -S -o - | FileCheck %s
 ; RUN: llc %s --filetype=obj -o - | obj2yaml | FileCheck %s --check-prefix=DXC
 target triple = "dxil-unknown-shadermodel6.5-library"
 
Index: llvm/test/CodeGen/DirectX/ContainerData/DebugShaderHash.ll
===================================================================
--- llvm/test/CodeGen/DirectX/ContainerData/DebugShaderHash.ll
+++ llvm/test/CodeGen/DirectX/ContainerData/DebugShaderHash.ll
@@ -1,4 +1,4 @@
-; RUN: llc %s --filetype=asm -o - | FileCheck %s
+; RUN: opt %s -dxil-embed -dxil-globals -S -o - | FileCheck %s
 ; RUN: llc %s --filetype=obj -o - | obj2yaml | FileCheck %s --check-prefix=DXC
 target triple = "dxil-unknown-shadermodel6.5-library"
 
Index: llvm/lib/Target/DirectX/DirectXTargetMachine.cpp
===================================================================
--- llvm/lib/Target/DirectX/DirectXTargetMachine.cpp
+++ llvm/lib/Target/DirectX/DirectXTargetMachine.cpp
@@ -42,6 +42,7 @@
   initializeDXILPrepareModulePass(*PR);
   initializeEmbedDXILPassPass(*PR);
   initializeWriteDXILPassPass(*PR);
+  initializeDXContainerGlobalsPass(*PR);
   initializeDXILOpLoweringLegacyPass(*PR);
   initializeDXILTranslateMetadataPass(*PR);
   initializeDXILResourceWrapperPass(*PR);
@@ -127,12 +128,6 @@
   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 @@
     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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158051.550609.patch
Type: text/x-patch
Size: 2939 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230816/472db0d6/attachment.bin>


More information about the llvm-commits mailing list