Skip to content

Commit e702f01

Browse files
committed
review: improve error messages + handling
1 parent 2694495 commit e702f01

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,14 @@ class DiagnosticInfoValidateMD : public DiagnosticInfo {
5858
}
5959
};
6060

61-
static bool reportError(Module &M, Twine Message,
61+
static void reportError(Module &M, Twine Message,
6262
DiagnosticSeverity Severity = DS_Error) {
6363
M.getContext().diagnose(DiagnosticInfoValidateMD(M, Message, Severity));
64-
return true;
6564
}
6665

67-
static bool reportLoopError(Module &M, Twine Message,
66+
static void reportLoopError(Module &M, Twine Message,
6867
DiagnosticSeverity Severity = DS_Error) {
69-
return reportError(M, Twine("Invalid \"llvm.loop\" metadata: ") + Message,
70-
Severity);
68+
reportError(M, Twine("Invalid \"llvm.loop\" metadata: ") + Message, Severity);
7169
}
7270

7371
enum class EntryPropsTag {
@@ -358,13 +356,13 @@ static bool isLoopMDCompatible(Module &M, Metadata *MD) {
358356

359357
if (HintStr->getString() == "llvm.loop.unroll.count") {
360358
if (!ValidCountNode(HintMD)) {
361-
reportLoopError(M, "Second operand of \"llvm.loop.unroll.count\" "
362-
"must be a constant integer");
359+
reportLoopError(M, "\"llvm.loop.unroll.count\" must have 2 operands and "
360+
"the second must be a constant integer");
363361
return false;
364362
}
365363
} else if (HintMD->getNumOperands() != 1) {
366364
reportLoopError(
367-
M, "\"llvm.loop.unroll.disable\" and \"llvm.loop.unroll.disable\" "
365+
M, "\"llvm.loop.unroll.disable\" and \"llvm.loop.unroll.full\" "
368366
"must be provided as a single operand");
369367
return false;
370368
}

llvm/test/CodeGen/DirectX/Metadata/loop-md-errs.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ exit:
6161

6262
;--- invalid-disable.ll
6363

64-
; CHECK: Invalid "llvm.loop" metadata: "llvm.loop.unroll.disable" and "llvm.loop.unroll.disable" must be provided as a single operand
64+
; CHECK: Invalid "llvm.loop" metadata: "llvm.loop.unroll.disable" and "llvm.loop.unroll.full" must be provided as a single operand
6565

6666
target triple = "dxilv1.0-unknown-shadermodel6.0-library"
6767

@@ -88,7 +88,7 @@ exit:
8888

8989
;--- invalid-full.ll
9090

91-
; CHECK: Invalid "llvm.loop" metadata: "llvm.loop.unroll.disable" and "llvm.loop.unroll.disable" must be provided as a single operand
91+
; CHECK: Invalid "llvm.loop" metadata: "llvm.loop.unroll.disable" and "llvm.loop.unroll.full" must be provided as a single operand
9292

9393
target triple = "dxilv1.0-unknown-shadermodel6.0-library"
9494

0 commit comments

Comments
 (0)