Skip to content

Commit 47b01f7

Browse files
author
joaosaffran
committed
clean up
1 parent 5aac761 commit 47b01f7

File tree

3 files changed

+14
-18
lines changed

3 files changed

+14
-18
lines changed

llvm/lib/Object/DXContainer.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include "llvm/Object/Error.h"
1212
#include "llvm/Support/Alignment.h"
1313
#include "llvm/Support/Endian.h"
14-
#include "llvm/Support/Error.h"
1514
#include "llvm/Support/FormatVariadic.h"
1615

1716
using namespace llvm;

llvm/lib/Target/DirectX/DXILRootSignature.cpp

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -102,30 +102,26 @@ bool ModuleRootSignature::parse(NamedMDNode *Root, const Function *EF) {
102102
return reportError("Invalid format for Root Signature Definition. Pairs "
103103
"of function, root signature expected.");
104104

105-
Metadata *MD = Node->getOperand(0).get();
106-
if (auto *VAM = llvm::dyn_cast<llvm::ValueAsMetadata>(MD)) {
107-
llvm::Value *V = VAM->getValue();
108-
if (Function *F = dyn_cast<Function>(V)) {
109-
if (F != EF)
110-
continue;
111-
} else {
112-
return reportError(
113-
"Root Signature MD node, first element is not a function.");
114-
}
115-
} else {
116-
return reportError(
117-
"Root Signature MD node, first element is not a function.");
118-
}
105+
ValueAsMetadata *VAM =
106+
llvm::dyn_cast<ValueAsMetadata>(Node->getOperand(0).get());
107+
if (VAM == nullptr)
108+
return reportError("First element of root signature is not a value");
109+
110+
Function *F = dyn_cast<Function>(VAM->getValue());
111+
if (F == nullptr)
112+
return reportError("First element of root signature is not a function");
113+
114+
if (F != EF)
115+
continue;
119116

120117
// Get the Root Signature Description from the function signature pair.
121118
MDNode *RS = dyn_cast<MDNode>(Node->getOperand(1).get());
122119

123120
if (RS == nullptr)
124-
return reportError("Missing Root Signature Metadata node.");
121+
return reportError("Missing Root Element List Metadata node.");
125122

126123
// Loop through the Root Elements of the root signature.
127124
for (unsigned int Eid = 0; Eid < RS->getNumOperands(); Eid++) {
128-
129125
MDNode *Element = dyn_cast<MDNode>(RS->getOperand(Eid));
130126
if (Element == nullptr)
131127
return reportError("Missing Root Element Metadata Node.");

llvm/lib/Target/DirectX/DXILRootSignature.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,14 @@ enum class RootSignatureElementKind {
3535
struct ModuleRootSignature {
3636
uint32_t Flags = 0;
3737
ModuleRootSignature() { Ctx = nullptr; };
38-
ModuleRootSignature(LLVMContext *Ctx) : Ctx(Ctx) {}
3938
static std::optional<ModuleRootSignature> analyzeModule(Module &M,
4039
const Function *F);
4140

4241
private:
4342
LLVMContext *Ctx;
4443

44+
ModuleRootSignature(LLVMContext *Ctx) : Ctx(Ctx) {}
45+
4546
bool parse(NamedMDNode *Root, const Function *F);
4647
bool parseRootSignatureElement(MDNode *Element);
4748
bool parseRootFlags(MDNode *RootFlagNode);

0 commit comments

Comments
 (0)