[llvm] 72017fc - [DirectX] Only embed dxil when writing object files

Justin Bogner via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 16 13:13:35 PDT 2023


Author: Justin Bogner
Date: 2023-08-16T13:12:32-07:00
New Revision: 72017fcf00b33b99aac604355d260910b1d57dfc

URL: https://github.com/llvm/llvm-project/commit/72017fcf00b33b99aac604355d260910b1d57dfc
DIFF: https://github.com/llvm/llvm-project/commit/72017fcf00b33b99aac604355d260910b1d57dfc.diff

LOG: [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

Added: 
    

Modified: 
    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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp b/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp
index 59e6fcb44d5aef..1111bb86e1c14d 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);

diff  --git a/llvm/test/CodeGen/DirectX/ContainerData/DebugShaderHash.ll b/llvm/test/CodeGen/DirectX/ContainerData/DebugShaderHash.ll
index 26788260475eef..eda0d6850bde59 100644
--- a/llvm/test/CodeGen/DirectX/ContainerData/DebugShaderHash.ll
+++ b/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"
 

diff  --git a/llvm/test/CodeGen/DirectX/ContainerData/ShaderHash.ll b/llvm/test/CodeGen/DirectX/ContainerData/ShaderHash.ll
index 02008722b8a53a..088a7b00716632 100644
--- a/llvm/test/CodeGen/DirectX/ContainerData/ShaderHash.ll
+++ b/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"
 

diff  --git a/llvm/test/CodeGen/DirectX/embed-dxil.ll b/llvm/test/CodeGen/DirectX/embed-dxil.ll
index b9a3e8ccd0719b..306e5c385b5a31 100644
--- a/llvm/test/CodeGen/DirectX/embed-dxil.ll
+++ b/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"


        


More information about the llvm-commits mailing list