[mlir] Don't emit unused labels

Stop the Cpp target from emitting unused labels. The previosly generated
code generated warning if `-Wunused-label` is passed to a compiler.

Co-authored-by: Simon Camphausen <simon.camphausen@iml.fraunhofer.de>

Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D118154
This commit is contained in:
Marius Brehler 2022-01-25 16:13:30 +00:00
parent 4ad517e6b0
commit 578122c18a
2 changed files with 2 additions and 5 deletions

View File

@ -631,8 +631,8 @@ static LogicalResult printOperation(CppEmitter &emitter, FuncOp functionOp) {
}
for (Block &block : blocks) {
// Only print a label if there is more than one block.
if (blocks.size() > 1) {
// Only print a label if the block has predecessors.
if (!block.hasNoPredecessors()) {
if (failed(emitter.emitLabel(block)))
return failure();
}

View File

@ -22,7 +22,6 @@ func @simple(i64, i1) -> i64 {
// CPP-DECLTOP-NEXT: int64_t [[C:[^ ]*]];
// CPP-DECLTOP-NEXT: int64_t [[D:[^ ]*]];
// CPP-DECLTOP-NEXT: int64_t [[E:[^ ]*]];
// CPP-DECLTOP-NEXT: [[BB0:[^ ]*]]:
// CPP-DECLTOP-NEXT: if ([[COND]]) {
// CPP-DECLTOP-NEXT: goto [[BB1:[^ ]*]];
// CPP-DECLTOP-NEXT: } else {
@ -51,7 +50,6 @@ func @block_labels0() {
return
}
// CPP-DECLTOP: void block_labels0() {
// CPP-DECLTOP-NEXT: label1:
// CPP-DECLTOP-NEXT: goto label2;
// CPP-DECLTOP-NEXT: label2:
// CPP-DECLTOP-NEXT: return;
@ -66,7 +64,6 @@ func @block_labels1() {
return
}
// CPP-DECLTOP: void block_labels1() {
// CPP-DECLTOP-NEXT: label1:
// CPP-DECLTOP-NEXT: goto label2;
// CPP-DECLTOP-NEXT: label2:
// CPP-DECLTOP-NEXT: return;