Skip to content

Commit 8f0f2a6

Browse files
committed
Address PR feedback
1 parent 3463780 commit 8f0f2a6

File tree

4 files changed

+14
-23
lines changed

4 files changed

+14
-23
lines changed

llvm/include/llvm/Analysis/DXILMetadataAnalysis.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace dxil {
2323
struct EntryProperties {
2424
const Function *Entry{nullptr};
2525
// Specific target shader stage may be specified for entry functions
26-
Triple::EnvironmentType ShaderStage = Triple::UnknownEnvironment;
26+
Triple::EnvironmentType ShaderStage{Triple::UnknownEnvironment};
2727
unsigned NumThreadsX{0}; // X component
2828
unsigned NumThreadsY{0}; // Y component
2929
unsigned NumThreadsZ{0}; // Z component
@@ -34,7 +34,7 @@ struct EntryProperties {
3434
struct ModuleMetadataInfo {
3535
VersionTuple DXILVersion{};
3636
VersionTuple ShaderModelVersion{};
37-
Triple::EnvironmentType ShaderProfile = Triple::UnknownEnvironment;
37+
Triple::EnvironmentType ShaderProfile{Triple::UnknownEnvironment};
3838
VersionTuple ValidatorVersion{};
3939
SmallVector<EntryProperties> EntryPropertyVec{};
4040
void print(raw_ostream &OS) const;

llvm/lib/Target/DirectX/DXILPrepare.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,7 @@ class DXILPrepareModule : public ModulePass {
248248
DXILPrepareModule() : ModulePass(ID) {}
249249
void getAnalysisUsage(AnalysisUsage &AU) const override {
250250
AU.setPreservesAll();
251-
AU.addPreserved<ShaderFlagsAnalysisWrapper>();
252-
AU.addPreserved<DXILResourceMDWrapper>();
253251
AU.addRequired<DXILMetadataAnalysisWrapperPass>();
254-
AU.addPreserved<DXILResourceWrapperPass>();
255252
}
256253
static char ID; // Pass identification.
257254
};

llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "llvm/IR/Module.h"
2525
#include "llvm/InitializePasses.h"
2626
#include "llvm/Pass.h"
27+
#include "llvm/Support/ErrorHandling.h"
2728
#include "llvm/Support/VersionTuple.h"
2829
#include "llvm/TargetParser/Triple.h"
2930
#include <cstdint>
@@ -34,7 +35,7 @@ using namespace llvm::dxil;
3435
/// A simple Wrapper DiagnosticInfo that generates Module-level diagnostic
3536
class DiagnosticInfoModuleFormat : public DiagnosticInfo {
3637
private:
37-
Twine Msg;
38+
const Twine Msg;
3839
const Module &Mod;
3940

4041
public:
@@ -45,12 +46,6 @@ class DiagnosticInfoModuleFormat : public DiagnosticInfo {
4546
DiagnosticSeverity Severity = DS_Error)
4647
: DiagnosticInfo(DK_Unsupported, Severity), Msg(Msg), Mod(M) {}
4748

48-
static bool classof(const DiagnosticInfo *DI) {
49-
return DI->getKind() == DK_Unsupported;
50-
}
51-
52-
const Twine &getMessage() const { return Msg; }
53-
5449
void print(DiagnosticPrinter &DP) const override {
5550
std::string Str;
5651
raw_string_ostream OS(Str);
@@ -166,7 +161,7 @@ getTagValueAsMetadata(EntryPropsTag Tag, uint64_t Value, LLVMContext &Ctx) {
166161
ConstantInt::get(Type::getInt32Ty(Ctx), Value)));
167162
break;
168163
default:
169-
assert(false && "NYI: Unhandled entry property tag");
164+
llvm_unreachable("NYI: Unhandled entry property tag");
170165
}
171166
return MDVals;
172167
}
@@ -191,13 +186,12 @@ getEntryPropAsMetadata(const EntryProperties &EP, uint64_t EntryShaderFlags,
191186
if (EP.ShaderStage == Triple::EnvironmentType::Compute) {
192187
MDVals.emplace_back(ConstantAsMetadata::get(
193188
ConstantInt::get(Type::getInt32Ty(Ctx), NumThreadsTag)));
194-
std::vector<Metadata *> NumThreadVals;
195-
NumThreadVals.emplace_back(ConstantAsMetadata::get(
196-
ConstantInt::get(Type::getInt32Ty(Ctx), EP.NumThreadsX)));
197-
NumThreadVals.emplace_back(ConstantAsMetadata::get(
198-
ConstantInt::get(Type::getInt32Ty(Ctx), EP.NumThreadsY)));
199-
NumThreadVals.emplace_back(ConstantAsMetadata::get(
200-
ConstantInt::get(Type::getInt32Ty(Ctx), EP.NumThreadsZ)));
189+
Metadata *NumThreadVals[] = {ConstantAsMetadata::get(ConstantInt::get(
190+
Type::getInt32Ty(Ctx), EP.NumThreadsX)),
191+
ConstantAsMetadata::get(ConstantInt::get(
192+
Type::getInt32Ty(Ctx), EP.NumThreadsY)),
193+
ConstantAsMetadata::get(ConstantInt::get(
194+
Type::getInt32Ty(Ctx), EP.NumThreadsZ))};
201195
MDVals.emplace_back(MDNode::get(Ctx, NumThreadVals));
202196
}
203197
}
@@ -333,8 +327,8 @@ static void translateMetadata(Module &M, const DXILResourceMap &DRM,
333327
if (MMDI.ShaderProfile != Triple::EnvironmentType::Library) {
334328
if (EntryProp.ShaderStage != MMDI.ShaderProfile) {
335329
M.getContext().diagnose(DiagnosticInfoModuleFormat(
336-
M, "Non-library shader: Stage of Shader entry different from "
337-
"target profile"));
330+
M, "Non-library shader: Stage of shader entry different from "
331+
"shader target profile"));
338332
}
339333
}
340334
EntryFnMDNodes.emplace_back(emitEntryMD(EntryProp, Signatures, ResourceMD,

llvm/test/CodeGen/DirectX/Metadata/target-profile-error.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
target triple = "dxil-pc-shadermodel6.6-pixel"
44

5-
; CHECK: Non-library shader: Stage of Shader entry different from target profile
5+
; CHECK: Non-library shader: Stage of shader entry different from shader target profile
66

77
define void @entry() #0 {
88
entry:

0 commit comments

Comments
 (0)