Skip to content

Commit 39167e7

Browse files
committed
Fix the bug by enabling extension for bool returns on x86_64
1 parent 294ff0f commit 39167e7

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

‎compiler/rustc_target/src/callconv/x86_64.rs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,10 @@ where
244244
if arg.layout.is_aggregate() {
245245
let size = arg.layout.size;
246246
arg.cast_to(cast_target(cls, size));
247-
} else if is_arg || cx.target_spec().is_like_darwin {
247+
} else if is_arg || cx.target_spec().is_like_darwin
248+
// Always extend bool returns
249+
|| (!is_arg && arg.layout.layout.backend_repr.is_bool())
250+
{
248251
arg.extend_integer_width_to(32);
249252
}
250253
}

‎tests/codegen-llvm/some-abis-do-extend-params-to-32-bits.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ pub extern "C" fn c_arg_i32(_a: i32) {}
134134
#[no_mangle]
135135
pub extern "C" fn c_arg_i64(_a: i64) {}
136136

137-
// x86_64-linux: i1 @c_ret_bool()
137+
// x86_64-linux: zeroext i1 @c_ret_bool()
138138
// x86_64-uefi: zeroext i1 @c_ret_bool()
139139
// i686: zeroext i1 @c_ret_bool()
140140
// aarch64-apple: zeroext i1 @c_ret_bool()

0 commit comments

Comments
 (0)