Skip to content

Commit 75277a6

Browse files
scottmcmRalfJung
andcommitted
Apply suggestions from code review
Co-authored-by: Ralf Jung <[email protected]>
1 parent 502af03 commit 75277a6

File tree

3 files changed

+3
-0
lines changed
  • compiler

3 files changed

+3
-0
lines changed

Diff for: compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1164,6 +1164,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
11641164
let params = vec![AbiParam::new(fx.pointer_type); 3];
11651165
let returns = vec![AbiParam::new(types::I32)];
11661166
let args = &[lhs_ptr, rhs_ptr, bytes_val];
1167+
// Here we assume that the `memcmp` provided by the target is a NOP for size 0.
11671168
let cmp = fx.lib_call("memcmp", params, returns, args)[0];
11681169
ret.write_cvalue(fx, CValue::by_val(cmp, ret.layout()));
11691170
}

Diff for: compiler/rustc_codegen_gcc/src/intrinsic/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
311311
let a_ptr = self.bitcast(a, void_ptr_type);
312312
let b_ptr = self.bitcast(b, void_ptr_type);
313313

314+
// Here we assume that the `memcmp` provided by the target is a NOP for size 0.
314315
let builtin = self.context.get_builtin_function("memcmp");
315316
let cmp = self.context.new_call(None, builtin, &[a_ptr, b_ptr, n]);
316317
self.sext(cmp, self.type_ix(32))

Diff for: compiler/rustc_codegen_llvm/src/intrinsic.rs

+1
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> {
330330
}
331331

332332
sym::compare_bytes => {
333+
// Here we assume that the `memcmp` provided by the target is a NOP for size 0.
333334
let cmp = self.call_intrinsic(
334335
"memcmp",
335336
&[args[0].immediate(), args[1].immediate(), args[2].immediate()],

0 commit comments

Comments
 (0)