Skip to content

Commit 5f823f7

Browse files
committed
Don't polyfill i128 for compiler-builtins
1 parent 49708a2 commit 5f823f7

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

Cargo.lock

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/rustc_codegen_nvvm/src/builder.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use rustc_middle::ty::layout::{
2222
use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
2323
use rustc_session::config::OptLevel;
2424
use rustc_span::Span;
25+
use rustc_span::def_id::LOCAL_CRATE;
2526
use rustc_target::callconv::FnAbi;
2627
use rustc_target::spec::{HasTargetSpec, Target};
2728
use tracing::{debug, trace};
@@ -136,7 +137,14 @@ macro_rules! imath_builder_methods {
136137
($($self_:ident.$name:ident($($arg:ident),*) => $llvm_capi:ident => $op:block)+) => {
137138
$(fn $name(&mut $self_, $($arg: &'ll Value),*) -> &'ll Value {
138139
// Dispatch to i128 emulation when any operand is 128 bits wide.
139-
if $($self_.is_i128($arg))||*
140+
// When compiling compiler_builtins itself we must avoid emulation that recursively calls
141+
// the same builtins, so fall back to LLVM's native operation.
142+
if $self_.cx.tcx.is_compiler_builtins(LOCAL_CRATE) {
143+
unsafe {
144+
trace!("binary expr (builtin crate): {:?} with args {:?}", stringify!($name), [$($arg),*]);
145+
llvm::$llvm_capi($self_.llbuilder, $($arg,)* UNNAMED)
146+
}
147+
} else if $($self_.is_i128($arg))||*
140148
$op
141149
else {
142150
unsafe {

0 commit comments

Comments
 (0)