Skip to content

Commit 9ebb68d

Browse files
committed
Rework OperandRef::extract_field to stop calling to_immediate_scalar on things which are already immediates
That means it stops trying to truncate things that are already `i1`s.
1 parent 51911a7 commit 9ebb68d

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

src/builder.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -989,10 +989,14 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
989989
OperandValue::Ref(place.val)
990990
} else if place.layout.is_gcc_immediate() {
991991
let load = self.load(place.layout.gcc_type(self), place.val.llval, place.val.align);
992-
if let abi::BackendRepr::Scalar(ref scalar) = place.layout.backend_repr {
993-
scalar_load_metadata(self, load, scalar);
994-
}
995-
OperandValue::Immediate(self.to_immediate(load, place.layout))
992+
OperandValue::Immediate(
993+
if let abi::BackendRepr::Scalar(ref scalar) = place.layout.backend_repr {
994+
scalar_load_metadata(self, load, scalar);
995+
self.to_immediate_scalar(load, *scalar)
996+
} else {
997+
load
998+
},
999+
)
9961000
} else if let abi::BackendRepr::ScalarPair(ref a, ref b) = place.layout.backend_repr {
9971001
let b_offset = a.size(self).align_to(b.align(self).abi);
9981002

src/intrinsic/mod.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use gccjit::FunctionType;
99
use gccjit::{ComparisonOp, Function, RValue, ToRValue, Type, UnaryOp};
1010
#[cfg(feature = "master")]
1111
use rustc_abi::ExternAbi;
12-
use rustc_abi::HasDataLayout;
12+
use rustc_abi::{BackendRepr, HasDataLayout};
1313
use rustc_codegen_ssa::MemFlags;
1414
use rustc_codegen_ssa::base::wants_msvc_seh;
1515
use rustc_codegen_ssa::common::IntPredicate;
@@ -181,14 +181,19 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tc
181181
sym::volatile_load | sym::unaligned_volatile_load => {
182182
let tp_ty = fn_args.type_at(0);
183183
let ptr = args[0].immediate();
184+
let layout = self.layout_of(tp_ty);
184185
let load = if let PassMode::Cast { cast: ref ty, pad_i32: _ } = fn_abi.ret.mode {
185186
let gcc_ty = ty.gcc_type(self);
186187
self.volatile_load(gcc_ty, ptr)
187188
} else {
188-
self.volatile_load(self.layout_of(tp_ty).gcc_type(self), ptr)
189+
self.volatile_load(layout.gcc_type(self), ptr)
189190
};
190191
// TODO(antoyo): set alignment.
191-
self.to_immediate(load, self.layout_of(tp_ty))
192+
if let BackendRepr::Scalar(scalar) = layout.backend_repr {
193+
self.to_immediate_scalar(load, scalar)
194+
} else {
195+
load
196+
}
192197
}
193198
sym::volatile_store => {
194199
let dst = args[0].deref(self.cx());

0 commit comments

Comments
 (0)