Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build_system/src/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ fn clean_ui_tests() -> Result<(), String> {
let path = Path::new(crate::BUILD_DIR)
.join("rust/build/x86_64-unknown-linux-gnu/test/")
.join(directory);
run_command(&[&"find", &path, &"-name", &"stamp", &"-delete"], None)?;
// The directory might not exist, so ignore the error.
let _ = run_command(&[&"find", &path, &"-name", &"stamp", &"-delete"], None);
}
Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion build_system/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,6 @@ fn contains_ui_error_patterns(file_path: &Path, keep_lto_tests: bool) -> Result<
"//@ known-bug",
"-Cllvm-args",
"//~",
"thread",
]
.iter()
.any(|check| line.contains(check))
Expand Down Expand Up @@ -1248,6 +1247,7 @@ fn run_ui_tests(env: &Env, args: &TestArg) -> Result<(), String> {
&"--compiletest-rustc-args",
&rustc_args,
&"--bypass-ignore-backends",
&"--force-rerun",
];

for test_name in &args.test_args {
Expand Down
2 changes: 1 addition & 1 deletion libgccjit.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6249f1b21d0c17856c6fa87def9edd0eaa968caf
31396c2f72909f5973b6acab17242f4e4fece99a
66 changes: 33 additions & 33 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
self.atomic_load(dst.get_type(), dst, load_ordering, Size::from_bytes(size));
let previous_var =
func.new_local(self.location, previous_value.get_type(), "previous_value");
let return_value = func.new_local(self.location, previous_value.get_type(), "return_value");
let return_value = self.new_temp(func, self.location, previous_value.get_type());
self.llbb().add_assignment(self.location, previous_var, previous_value);
self.llbb().add_assignment(self.location, return_value, previous_var.to_rvalue());

Expand Down Expand Up @@ -359,11 +359,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
let void_type = self.context.new_type::<()>();
let current_func = self.block.get_function();
if return_type != void_type {
let result = current_func.new_local(
self.location,
return_type,
format!("returnValue{}", self.next_value_counter()),
);
let result = self.new_temp(current_func, self.location, return_type);
self.block.add_assignment(self.location, result, call);
result.to_rvalue()
} else {
Expand Down Expand Up @@ -427,11 +423,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
args_adjusted,
orig_args,
);
let result = current_func.new_local(
self.location,
return_value.get_type(),
format!("ptrReturnValue{}", self.next_value_counter()),
);
let result = self.new_temp(current_func, self.location, return_value.get_type());
self.block.add_assignment(self.location, result, return_value);
result.to_rvalue()
} else {
Expand Down Expand Up @@ -477,11 +469,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
let return_type = self.context.new_type::<bool>();
let current_func = self.block.get_function();
// FIXME(antoyo): return the new_call() directly? Since the overflow function has no side-effects.
let result = current_func.new_local(
self.location,
return_type,
format!("overflowReturnValue{}", self.next_value_counter()),
);
let result = self.new_temp(current_func, self.location, return_type);
self.block.add_assignment(
self.location,
result,
Expand Down Expand Up @@ -671,8 +659,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
let call = self.call(typ, fn_attrs, fn_abi, func, args, None, instance); // FIXME(antoyo): use funclet here?
self.block = current_block;

let return_value =
self.current_func().new_local(self.location, call.get_type(), "invokeResult");
let return_value = self.new_temp(self.current_func(), self.location, call.get_type());

try_block.add_assignment(self.location, return_value, call);

Expand Down Expand Up @@ -719,8 +706,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
if return_type == void_type {
self.block.end_with_void_return(self.location)
} else {
let return_value =
self.current_func().new_local(self.location, return_type, "unreachableReturn");
let return_value = self.new_temp(self.current_func(), self.location, return_type);
self.block.end_with_return(self.location, return_value)
}
}
Expand Down Expand Up @@ -1039,11 +1025,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
// the current basic block. Otherwise, it could be used in another basic block, causing a
// dereference after a drop, for instance.
let deref = ptr.dereference(self.location).to_rvalue();
let loaded_value = function.new_local(
self.location,
aligned_type,
format!("loadedValue{}", self.next_value_counter()),
);
let loaded_value = self.new_temp(function, self.location, aligned_type);
block.add_assignment(self.location, loaded_value, deref);
loaded_value.to_rvalue()
}
Expand Down Expand Up @@ -1161,7 +1143,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
let next_bb = self.append_sibling_block("repeat_loop_next");

let ptr_type = start.get_type();
let current = self.llbb().get_function().new_local(self.location, ptr_type, "loop_var");
let current = self.new_temp(self.llbb().get_function(), self.location, ptr_type);
let current_val = current.to_rvalue();
self.assign(current, start);

Expand Down Expand Up @@ -1526,7 +1508,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
mut else_val: RValue<'gcc>,
) -> RValue<'gcc> {
let func = self.current_func();
let variable = func.new_local(self.location, then_val.get_type(), "selectVar");
let variable = self.new_temp(func, self.location, then_val.get_type());
let then_block = func.new_block("then");
let else_block = func.new_block("else");
let after_block = func.new_block("after");
Expand Down Expand Up @@ -1672,11 +1654,9 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
#[cfg(not(feature = "master"))]
fn cleanup_landing_pad(&mut self, _pers_fn: Function<'gcc>) -> (RValue<'gcc>, RValue<'gcc>) {
let value1 = self
.current_func()
.new_local(self.location, self.u8_type.make_pointer(), "landing_pad0")
.new_temp(self.current_func(), self.location, self.u8_type.make_pointer())
.to_rvalue();
let value2 =
self.current_func().new_local(self.location, self.i32_type, "landing_pad1").to_rvalue();
let value2 = self.new_temp(self.current_func(), self.location, self.i32_type).to_rvalue();
(value1, value2)
}

Expand Down Expand Up @@ -1744,7 +1724,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {

// NOTE: since success contains the call to the intrinsic, it must be added to the basic block before
// expected so that we store expected after the call.
let success_var = self.current_func().new_local(self.location, self.bool_type, "success");
let success_var = self.new_temp(self.current_func(), self.location, self.bool_type);
self.llbb().add_assignment(self.location, success_var, success);

(expected.to_rvalue(), success_var.to_rvalue())
Expand Down Expand Up @@ -2445,11 +2425,31 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
self.bitcast_if_needed(res, result_type)
}

/// Create a temporary variable.
///
/// GCC will use more stack space with a local variable than with a temporary variable in debug mode,
/// so in order to avoid having the stack probe test fail in CI, we avoid creating local variables for temporaries.
pub fn new_temp(
&self,
function: Function<'gcc>,
location: Option<Location<'gcc>>,
typ: Type<'gcc>,
) -> LValue<'gcc> {
#[cfg(feature = "master")]
{
function.new_temp(location, typ)
}
#[cfg(not(feature = "master"))]
{
function.new_local(location, typ, format!("temp{}", self.next_value_counter()))
}
}

// GCC doesn't like deeply nested expressions.
// By assigning intermediate expressions to a variable, this allow us to avoid deeply nested
// expressions and GCC will use much less RAM.
fn assign_to_var(&self, value: RValue<'gcc>) -> RValue<'gcc> {
let var = self.current_func().new_local(self.location, value.get_type(), "opResult");
let var = self.new_temp(self.current_func(), self.location, value.get_type());
self.llbb().add_assignment(self.location, var, value);
var.to_rvalue()
}
Expand Down
11 changes: 10 additions & 1 deletion src/gcc_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use gccjit::Version;
use rustc_codegen_ssa::target_features;
use rustc_data_structures::smallvec::{SmallVec, smallvec};
use rustc_session::Session;
use rustc_target::spec::{Arch, RelocModel, StackProtector};
use rustc_target::spec::{Arch, RelocModel, StackProbeType, StackProtector};

fn gcc_features_by_flags(sess: &Session, features: &mut Vec<String>) {
target_features::retpoline_features_by_flags(sess, features);
Expand Down Expand Up @@ -211,6 +211,15 @@ pub fn new_context<'gcc>(sess: &Session) -> Context<'gcc> {
StackProtector::None => (),
}

match sess.target.stack_probes {
StackProbeType::None => (),
StackProbeType::Inline | StackProbeType::InlineOrCall { .. } => {
context.add_command_line_option("-fstack-clash-protection")
}
// FIXME(antoyo): We should define the stack probe symbol to be __rust_probestack, but it seems GCC cannot do that.
StackProbeType::Call => (),
};

add_pic_option(&context, sess.relocation_model());

let target_cpu = target_cpu(sess);
Expand Down
2 changes: 1 addition & 1 deletion src/int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
if self.is_non_native_int_type(a_type) || self.is_non_native_int_type(b_type) {
// This algorithm is based on compiler-rt's __cmpti2:
// https://github.com/llvm-mirror/compiler-rt/blob/f0745e8476f069296a7c71accedd061dce4cdf79/lib/builtins/cmpti2.c#L21
let result = self.current_func().new_local(self.location, self.int_type, "icmp_result");
let result = self.new_temp(self.current_func(), self.location, self.int_type);
let block1 = self.current_func().new_block("block1");
let block2 = self.current_func().new_block("block2");
let block3 = self.current_func().new_block("block3");
Expand Down
2 changes: 1 addition & 1 deletion src/intrinsic/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ pub fn adjust_intrinsic_return_value<'a, 'gcc, 'tcx>(
"__builtin_ia32_rdrand64_step" => {
let random_number = args[0].dereference(None).to_rvalue();
let success_variable =
builder.current_func().new_local(None, return_value.get_type(), "success");
builder.new_temp(builder.current_func(), None, return_value.get_type());
builder.llbb().add_assignment(None, success_variable, return_value);

let field1 = builder.context.new_field(None, random_number.get_type(), "random_number");
Expand Down
8 changes: 4 additions & 4 deletions src/intrinsic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
let else_block = func.new_block("else");
let after_block = func.new_block("after");

let result = func.new_local(None, self.u32_type, "zeros");
let result = self.new_temp(func, None, self.u32_type);
let zero = self.cx.gcc_zero(arg.get_type());
let cond = self.gcc_icmp(IntPredicate::IntEQ, arg, zero);
self.llbb().end_with_conditional(None, cond, then_block, else_block);
Expand Down Expand Up @@ -1017,7 +1017,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
// else call it on the 64 high bits and add 64. In the else case, 64 high bits can't be 0
// because arg is not 0.

let result = self.current_func().new_local(None, result_type, "count_zeroes_results");
let result = self.new_temp(self.current_func(), None, result_type);

let cz_then_block = self.current_func().new_block("cz_then");
let cz_else_block = self.current_func().new_block("cz_else");
Expand Down Expand Up @@ -1132,8 +1132,8 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
let loop_tail = func.new_block("tail");

let counter_type = self.int_type;
let counter = self.current_func().new_local(None, counter_type, "popcount_counter");
let val = self.current_func().new_local(None, value_type, "popcount_value");
let counter = self.new_temp(self.current_func(), None, counter_type);
let val = self.new_temp(self.current_func(), None, value_type);
let zero = self.gcc_zero(counter_type);
self.llbb().add_assignment(self.location, counter, zero);
self.llbb().add_assignment(self.location, val, value);
Expand Down
4 changes: 4 additions & 0 deletions tests/failing-lto-tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ tests/ui/uninhabited/uninhabited-transparent-return-abi.rs
tests/ui/coroutine/panic-drops-resume.rs
tests/ui/coroutine/panic-drops.rs
tests/ui/coroutine/panic-safe.rs
tests/ui/panic-handler/catch-unwind-during-unwind-68696.rs
tests/ui/threads-sendsync/task-stderr.rs
tests/ui/extern/issue-64655-allow-unwind-when-calling-panic-directly.rs
tests/ui/extern/issue-64655-extern-rust-must-allow-unwind.rs
27 changes: 26 additions & 1 deletion tests/failing-ui-tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,29 @@ tests/ui/explicit-tail-calls/tailcc-no-signature-restriction.rs
tests/ui/abi/rust-tail-cc.rs
tests/ui/abi/rust-preserve-none-cc.rs
tests/ui/extern/extern-types-field-offset.rs
tests/ui/abi/stack-probes-lto.rs
tests/ui/numbers-arithmetic/int-abs-overflow.rs
tests/ui/numbers-arithmetic/issue-8460.rs
tests/ui/panics/panic-handler-chain-update-hook.rs
tests/ui/panics/panic-handler-chain.rs
tests/ui/panics/panic-handler-set-twice.rs
tests/ui/panics/panic-recover-propagate.rs
tests/ui/panics/panic-in-dtor-drops-fields.rs
tests/ui/panics/panic-handler-flail-wildly.rs
tests/ui/panics/rvalue-cleanup-during-box-panic.rs
tests/ui/process/multi-panic.rs
tests/ui/sepcomp/sepcomp-unwind.rs
tests/ui/structs/unit-like-struct-drop-run.rs
tests/ui/threads-sendsync/unwind-resource.rs
tests/ui/array-slice-vec/box-of-array-of-drop-2.rs
tests/ui/array-slice-vec/box-of-array-of-drop-1.rs
tests/ui/array-slice-vec/nested-vec-3.rs
tests/ui/array-slice-vec/slice-panic-1.rs
tests/ui/array-slice-vec/slice-panic-2.rs
tests/ui/backtrace/synchronized-panic-handler.rs
tests/ui/cross-crate/mut-ref-write-visible-after-unwind.rs
tests/ui/drop/drop-once-on-panic.rs
tests/ui/drop/enum-destructor-on-unwind.rs
tests/ui/drop/drop-trait-enum.rs
tests/ui/drop/panic-during-slice-init.rs
tests/ui/drop/terminate-in-initializer.rs
tests/ui/eii/track_caller.rs
Loading