-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[mlir][tblgen] Avoid compilation failure #161545
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This would have failed during compilation post generation later, trim and use raw string literals to avoid such failures.
Member
|
@llvm/pr-subscribers-mlir-core @llvm/pr-subscribers-mlir Author: Jacques Pienaar (jpienaar) ChangesThis would have failed during compilation post generation later, trim and use raw string literals to avoid such failures. Probably a few more places where similar failures could occur, but this was unexpected failure user ran into. Full diff: https://github.com/llvm/llvm-project/pull/161545.diff 2 Files Affected:
diff --git a/mlir/tools/mlir-tblgen/PassGen.cpp b/mlir/tools/mlir-tblgen/PassGen.cpp
index 4b4ac41b9effb..f7134ce02b72f 100644
--- a/mlir/tools/mlir-tblgen/PassGen.cpp
+++ b/mlir/tools/mlir-tblgen/PassGen.cpp
@@ -195,7 +195,7 @@ class {0}Base : public {1} {
}
::llvm::StringRef getArgument() const override { return "{2}"; }
- ::llvm::StringRef getDescription() const override { return "{3}"; }
+ ::llvm::StringRef getDescription() const override { return R"PD({3})PD"; }
/// Returns the derived pass name.
static constexpr ::llvm::StringLiteral getPassName() {
@@ -271,9 +271,9 @@ static void emitPassOptionDecls(const Pass &pass, raw_ostream &os) {
os.indent(2) << "::mlir::Pass::"
<< (opt.isListOption() ? "ListOption" : "Option");
- os << formatv(R"(<{0}> {1}{{*this, "{2}", ::llvm::cl::desc("{3}"))",
+ os << formatv(R"(<{0}> {1}{{*this, "{2}", ::llvm::cl::desc(R"PO({3})PO"))",
opt.getType(), opt.getCppVariableName(), opt.getArgument(),
- opt.getDescription());
+ opt.getDescription().trim());
if (std::optional<StringRef> defaultVal = opt.getDefaultValue())
os << ", ::llvm::cl::init(" << defaultVal << ")";
if (std::optional<StringRef> additionalFlags = opt.getAdditionalFlags())
@@ -285,9 +285,10 @@ static void emitPassOptionDecls(const Pass &pass, raw_ostream &os) {
/// Emit the declarations for each of the pass statistics.
static void emitPassStatisticDecls(const Pass &pass, raw_ostream &os) {
for (const PassStatistic &stat : pass.getStatistics()) {
- os << formatv(" ::mlir::Pass::Statistic {0}{{this, \"{1}\", \"{2}\"};\n",
- stat.getCppVariableName(), stat.getName(),
- stat.getDescription());
+ os << formatv(
+ " ::mlir::Pass::Statistic {0}{{this, \"{1}\", R\"PS({2})PS\"};\n",
+ stat.getCppVariableName(), stat.getName(),
+ stat.getDescription().trim());
}
}
@@ -320,7 +321,7 @@ static void emitPassDefs(const Pass &pass, raw_ostream &os) {
os << "namespace impl {\n";
os << formatv(baseClassBegin, passName, pass.getBaseClass(),
- pass.getArgument(), pass.getSummary(),
+ pass.getArgument(), pass.getSummary().trim(),
dependentDialectRegistrations);
if (ArrayRef<PassOption> options = pass.getOptions(); !options.empty()) {
@@ -393,7 +394,7 @@ class {0}Base : public {1} {
}
::llvm::StringRef getArgument() const override { return "{2}"; }
- ::llvm::StringRef getDescription() const override { return "{3}"; }
+ ::llvm::StringRef getDescription() const override { return R"PD({3})PD"; }
/// Returns the derived pass name.
static constexpr ::llvm::StringLiteral getPassName() {
@@ -439,7 +440,7 @@ static void emitOldPassDecl(const Pass &pass, raw_ostream &os) {
"\n ");
}
os << formatv(oldPassDeclBegin, defName, pass.getBaseClass(),
- pass.getArgument(), pass.getSummary(),
+ pass.getArgument(), pass.getSummary().trim(),
dependentDialectRegistrations);
emitPassOptionDecls(pass, os);
emitPassStatisticDecls(pass, os);
diff --git a/mlir/unittests/TableGen/passes.td b/mlir/unittests/TableGen/passes.td
index 5e53cb99ef9fa..79c57a97bba7c 100644
--- a/mlir/unittests/TableGen/passes.td
+++ b/mlir/unittests/TableGen/passes.td
@@ -19,8 +19,11 @@ def TestPassWithOptions : Pass<"test"> {
let options = [
Option<"testOption", "testOption", "int", "0", "Test option">,
- ListOption<"testListOption", "test-list-option", "int64_t",
- "Test list option">
+ // Testing the output of multi-line description. This would fail compilation
+ // if not properly handled.
+ ListOption<"testListOption", "test-list-option", "int64_t", [{
+ Test
+ list option}]>
];
}
|
makslevental
approved these changes
Oct 13, 2025
DharuniRAcharya
pushed a commit
to DharuniRAcharya/llvm-project
that referenced
this pull request
Oct 13, 2025
This would have failed during compilation post generation later, trim and use raw string literals to avoid such failures. Probably a few more places where similar failures could occur, but this was unexpected failure user ran into.
akadutta
pushed a commit
to akadutta/llvm-project
that referenced
this pull request
Oct 14, 2025
This would have failed during compilation post generation later, trim and use raw string literals to avoid such failures. Probably a few more places where similar failures could occur, but this was unexpected failure user ran into.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This would have failed during compilation post generation later, trim and use raw string literals to avoid such failures.
Probably a few more places where similar failures could occur, but this was unexpected failure user ran into.