Skip to content

Commit 893c8a4

Browse files
r-barnesfacebook-github-bot
authored andcommitted
Fix unreachable-break issue in cinderx/Jit/hir/builder.cpp +5
Summary: LLVM has a warning `-Wunreachable-code-break` which identifies `break` statements that cannot be reached. These compromise readability, are misleading, and may identify bugs. This diff removes such statements. Such statements once existed to prevent accidental fallthroughs in switch statements. However, this is no longer necessary in C++17 because `[[fallthrough]]` is used to indicate intentional fallthroughs and we raise compilation errors for fallthroughs that are not annotated with `[[fallthrough]]` using `-Wimplicit-fallthrough`. For questions/comments, contact r-barnes. - If you approve of this diff, please use the "Accept & Ship" button :-) Reviewed By: dtolnay Differential Revision: D78275962 fbshipit-source-id: 58dde2d33830cc9eb0eab94a675811b186c763fc
1 parent 31ef033 commit 893c8a4

5 files changed

Lines changed: 0 additions & 17 deletions

File tree

Jit/hir/builder.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,6 @@ static bool should_snapshot(
478478
case WITH_EXCEPT_START: {
479479
JIT_ABORT(
480480
"Should not be compiling except blocks (opcode {})\n", bci.opcode());
481-
break;
482481
}
483482
// Take a snapshot after translating all other bytecode instructions. This
484483
// may generate unnecessary deoptimization metadata but will always be
@@ -1197,7 +1196,6 @@ void HIRBuilder::translate(
11971196
// BytecodeInstruction::getJumpTarget() to always skip the END_FOR so
11981197
// that block should never be processed.
11991198
JIT_ABORT("We should never cross an END_FOR in the HIR builder");
1200-
break;
12011199
}
12021200
case SETUP_FINALLY: {
12031201
emitSetupFinally(tc, bc_instr);
@@ -1482,7 +1480,6 @@ void HIRBuilder::translate(
14821480
bc_instr.opcode());
14831481
default: {
14841482
JIT_ABORT("Unhandled opcode: {}", bc_instr.opcode());
1485-
break;
14861483
}
14871484
}
14881485
}
@@ -2098,7 +2095,6 @@ static inline UnaryOpKind get_unary_op_kind(
20982095
default:
20992096
JIT_ABORT("Unhandled unary op {}", bc_instr.opcode());
21002097
// NOTREACHED
2101-
break;
21022098
}
21032099
}
21042100

@@ -2651,7 +2647,6 @@ void HIRBuilder::emitJumpIf(
26512647
// NOTREACHED
26522648
JIT_ABORT(
26532649
"Trying to translate non-jump-if bytecode: {}", bc_instr.opcode());
2654-
break;
26552650
}
26562651
}
26572652

@@ -3096,7 +3091,6 @@ static inline BinaryOpKind get_primitive_bin_op_kind(
30963091
default: {
30973092
JIT_ABORT("Unhandled binary op {}", bc_instr.oparg());
30983093
// NOTREACHED
3099-
break;
31003094
}
31013095
}
31023096
}
@@ -3130,7 +3124,6 @@ static inline bool is_double_binop(int oparg) {
31303124
default: {
31313125
JIT_ABORT("Invalid binary op {}", oparg);
31323126
// NOTREACHED
3133-
break;
31343127
}
31353128
}
31363129
}
@@ -3147,7 +3140,6 @@ static inline Type element_type_from_seq_type(int seq_type) {
31473140
default:
31483141
JIT_ABORT("Invalid sequence type: ({})", seq_type);
31493142
// NOTREACHED
3150-
break;
31513143
}
31523144
}
31533145

@@ -3217,7 +3209,6 @@ void HIRBuilder::emitPrimitiveCompare(
32173209
break;
32183210
default:
32193211
JIT_ABORT("unsupported comparison");
3220-
break;
32213212
}
32223213
tc.emit<PrimitiveCompare>(result, op, left, right);
32233214
stack.push(result);
@@ -3255,7 +3246,6 @@ void HIRBuilder::emitPrimitiveUnaryOp(
32553246
}
32563247
default: {
32573248
JIT_ABORT("unsupported unary op");
3258-
break;
32593249
}
32603250
}
32613251
tc.frame.stack.push(result);
@@ -3655,7 +3645,6 @@ void HIRBuilder::emitPopJumpIf(
36553645
// NOTREACHED
36563646
JIT_ABORT(
36573647
"Trying to translate non pop-jump bytecode: {}", bc_instr.opcode());
3658-
break;
36593648
}
36603649
}
36613650

@@ -4215,7 +4204,6 @@ void HIRBuilder::emitRaiseVarargs(
42154204
break;
42164205
default:
42174206
JIT_ABORT("Unsupported RAISE_VARARGS op: {}", bc_instr.oparg());
4218-
break;
42194207
}
42204208
}
42214209

Jit/hir/hir.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,6 @@ static void postorder_traverse(
609609
/* NOTREACHED */
610610
JIT_ABORT(
611611
"Block {} has invalid terminator {}", block->id, instr->opname());
612-
break;
613612
}
614613
}
615614

Jit/hir/optimization.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,6 @@ static void simplifyRedundantCondBranches(CFG* cfg) {
661661
default:
662662
// Can't be sure that it's safe to replace the instruction with a branch
663663
JIT_ABORT("Unknown side effects of {} instruction", term->opname());
664-
break;
665664
}
666665
to_simplify.emplace_back(&block);
667666
}

Jit/hir/parser.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,7 +1039,6 @@ HIRParser::parseInstr(std::string_view opcode, Register* dst, int bb_index) {
10391039
case Opcode::kYieldFrom:
10401040
case Opcode::kYieldFromHandleStopAsyncIteration: {
10411041
JIT_ABORT("Unsupported opcode: {}", opcode);
1042-
break;
10431042
}
10441043
}
10451044

@@ -1302,7 +1301,6 @@ RegState HIRParser::GetNextRegState() {
13021301
break;
13031302
default:
13041303
JIT_ABORT("Unknown ref kind: {}", token[0]);
1305-
break;
13061304
}
13071305

13081306
return rs;

Jit/hir/preload.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ Type prim_type_to_type(int prim_type) {
5353
return TCInt32;
5454
default:
5555
JIT_ABORT("Non-primitive or unsupported Python type: {}", prim_type);
56-
break;
5756
}
5857
}
5958

0 commit comments

Comments
 (0)