diff --git a/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp b/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp index 59e6fcb44d5ae..1111bb86e1c14 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 26788260475ee..eda0d6850bde5 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 02008722b8a53..088a7b0071663 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 b9a3e8ccd0719..306e5c385b5a3 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"