diff --git a/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp b/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp --- a/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp +++ b/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); diff --git a/llvm/test/CodeGen/DirectX/ContainerData/DebugShaderHash.ll b/llvm/test/CodeGen/DirectX/ContainerData/DebugShaderHash.ll --- 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 --- 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 --- 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"