Skip to content

Commit e300412

Browse files
committed
refactored the pass to PassManagerBuilder, updated a test
1 parent 33e384a commit e300412

6 files changed

Lines changed: 12 additions & 14 deletions

File tree

include/llvm/Transforms/IPO/PassManagerBuilder.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ class PassManagerBuilder {
140140
bool HLSLEnableDebugNops = false; // HLSL Change
141141
bool HLSLEarlyInlining = true; // HLSL Change
142142
bool HLSLNoSink = false; // HLSL Change
143+
bool StripDebug = false;
143144
void addHLSLPasses(legacy::PassManagerBase &MPM); // HLSL Change
144145

145146
private:

lib/Transforms/IPO/PassManagerBuilder.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ PassManagerBuilder::PassManagerBuilder() {
132132
VerifyOutput = false;
133133
MergeFunctions = false;
134134
PrepareForLTO = false;
135+
StripDebug = false;
135136
}
136137

137138
PassManagerBuilder::~PassManagerBuilder() {
@@ -393,6 +394,8 @@ void PassManagerBuilder::populateModulePassManager(
393394
MPM.add(createDxilDeleteRedundantDebugValuesPass());
394395
MPM.add(createNoPausePassesPass());
395396
MPM.add(createDxilEmitMetadataPass());
397+
if (StripDebug)
398+
MPM.add(createDxilStripDebugSensitiveInfoPass());
396399
}
397400
// HLSL Change Ends.
398401
return;
@@ -712,6 +715,8 @@ void PassManagerBuilder::populateModulePassManager(
712715
MPM.add(createNoPausePassesPass());
713716
MPM.add(createDxilValidateWaveSensitivityPass());
714717
MPM.add(createDxilEmitMetadataPass());
718+
if (StripDebug)
719+
MPM.add(createDxilStripDebugSensitiveInfoPass());
715720
}
716721
// HLSL Change Ends.
717722
addExtensionsToPM(EP_OptimizerLast, MPM);

tools/clang/include/clang/Frontend/CodeGenOptions.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ class CodeGenOptions : public CodeGenOptionsBase {
170170
/// Name of the profile file to use as input for -fprofile-instr-use
171171
std::string InstrProfileInput;
172172

173+
bool StripDebug = false;
174+
173175
/// A list of file names passed with -fcuda-include-gpubinary options to
174176
/// forward to CUDA runtime back-end for incorporating them into host-side
175177
/// object file.

tools/clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ void EmitAssemblyHelper::CreatePasses() {
361361
OptToggles.IsEnabled(hlsl::options::TOGGLE_PARTIAL_LIFETIME_MARKERS);
362362
PMBuilder.HLSLEnableAggressiveReassociation = OptToggles.IsEnabled(
363363
hlsl::options::TOGGLE_ENABLE_AGGRESSIVE_REASSOCIATION);
364+
PMBuilder.StripDebug = CodeGenOpts.StripDebug;
364365
// HLSL Change - end
365366

366367
PMBuilder.DisableUnitAtATime = !CodeGenOpts.UnitAtATime;

tools/clang/tools/dxcompiler/dxcompilerobj.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "clang/Sema/SemaHLSL.h"
2626
#include "llvm/Bitcode/ReaderWriter.h"
2727
#include "llvm/IR/LLVMContext.h"
28-
#include "llvm/IR/LegacyPassManager.h"
2928
#include "llvm/Support/TimeProfiler.h"
3029
#include "llvm/Support/Timer.h"
3130
#include "llvm/Transforms/Utils/Cloning.h"
@@ -35,7 +34,6 @@
3534
#include "dxc/DxcBindingTable/DxcBindingTable.h"
3635
#include "dxc/DxilContainer/DxilContainerAssembler.h"
3736
#include "dxc/DxilRootSignature/DxilRootSignature.h"
38-
#include "dxc/HLSL/DxilGenerationPass.h"
3937
#include "dxc/HLSL/HLSLExtensionsCodegenHelper.h"
4038
#include "dxc/Support/Path.h"
4139
#include "dxc/Support/WinIncludes.h"
@@ -1050,12 +1048,6 @@ class DxcCompiler : public IDxcCompiler3,
10501048

10511049
inputs.pVersionInfo = static_cast<IDxcVersionInfo *>(this);
10521050

1053-
if (opts.StripDebug) {
1054-
legacy::PassManager PM;
1055-
PM.add(createDxilStripDebugSensitiveInfoPass());
1056-
PM.run(*inputs.pM);
1057-
}
1058-
10591051
if (needsValidation) {
10601052
valHR = dxcutil::ValidateAndAssembleToContainer(inputs);
10611053
} else {
@@ -1616,6 +1608,7 @@ class DxcCompiler : public IDxcCompiler3,
16161608
Opts.EnableLifetimeMarkers;
16171609
compiler.getCodeGenOpts().HLSLEnablePayloadAccessQualifiers =
16181610
Opts.EnablePayloadQualifiers;
1611+
compiler.getCodeGenOpts().StripDebug = Opts.StripDebug;
16191612

16201613
// Translate signature packing options
16211614
if (Opts.PackPrefixStable)

tools/clang/unittests/HLSL/DxilContainerTest.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3092,15 +3092,11 @@ TEST_F(DxilContainerTest, StripReflectionRemovesStructNames) {
30923092
float4 color;
30933093
};
30943094
3095-
cbuffer MyCBuffer : register(b0) {
3096-
float4 data;
3097-
};
3098-
3099-
float4 main() : SV_Target {
3095+
MyCustomStruct main() : SV_Target {
31003096
MyCustomStruct s;
31013097
s.position = float4(0, 0, 0, 1);
31023098
s.color = float4(1, 1, 1, 1);
3103-
return s.color;
3099+
return s;
31043100
}
31053101
)";
31063102

0 commit comments

Comments
 (0)