Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

powerpc: ICE when taking and returning C struct containing u64 #47278

Closed
hanna-kruppe opened this issue Jan 8, 2018 · 2 comments
Closed

powerpc: ICE when taking and returning C struct containing u64 #47278

hanna-kruppe opened this issue Jan 8, 2018 · 2 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ O-PowerPC Target: PowerPC processors P-high High priority regression-from-stable-to-beta Performance or correctness regression from stable to beta.
Milestone

Comments

@hanna-kruppe
Copy link
Contributor

hanna-kruppe commented Jan 8, 2018

This code, when compiled for powerpc-unknown-linux-gnu, results in an ICE:

#[repr(C)]
pub struct Foo(u64);

pub extern fn foo(_: Foo) -> Foo { loop {} }

Putting smaller integers in Foo does not trigger this, even if you use a ton of them. Edit: It also does not occur when taking it only as argument, or when only returning it.

Panic message and backtrace:

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.25.0-nightly (ee220daca 2018-01-07) running on x86_64-pc-windows-msvc

note: run with `RUST_BACKTRACE=1` for a backtrace

thread 'rustc' panicked at 'out of bounds argument access: 3 out of 3 arguments', librustc_llvm\lib.rs:269:9
stack backtrace:
   0: std::sync::mpsc::sync::Queue::dequeue
   1: std::panicking::Location::column
   2: std::panicking::Location::column
   3: std::panicking::rust_panic_with_hook
   4: std::panicking::begin_panic_fmt
   5: std::panicking::begin_panic_fmt
   6: rustc_llvm::get_param
   7: <rustc_trans::abi::CastTarget as core::convert::From<rustc_trans::abi::Uniform>>::from
   8: <rustc_trans::cabi_x86_64::Class as core::fmt::Debug>::fmt
   9: <rustc_trans::mir::analyze::CleanupKind as core::fmt::Debug>::fmt
  10: rustc_trans::base::trans_instance
  11: <rustc_trans::mir::analyze::LocalAnalyzer<'mir, 'a, 'tcx> as rustc::mir::visit::Visitor<'tcx>>::visit_local
  12: rustc_trans::base::trans_crate
  13: rustc::ty::maps::<impl rustc::ty::maps::queries::compile_codegen_unit<'tcx>>::ensure
  14: rustc::dep_graph::graph::DepGraph::in_ignore
  15: rustc::util::ppaux::<impl core::fmt::Debug for rustc::ty::Predicate<'tcx>>::fmt
  16: <rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx> as rustc::ty::layout::HasTyCtxt<'gcx>>::tcx
  17: rustc::ty::maps::<impl rustc::ty::maps::queries::compile_codegen_unit<'tcx>>::ensure
  18: rustc::ty::maps::<impl rustc::ty::maps::queries::compile_codegen_unit<'tcx>>::try_get
  19: rustc::ty::maps::TyCtxtAt::compile_codegen_unit
  20: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::compile_codegen_unit
  21: rustc_trans::base::trans_crate
  22: <rustc_trans::LlvmTransCrate as rustc_trans_utils::trans_crate::TransCrate>::trans_crate
  23: rustc_driver::driver::default_provide_extern
  24: <rustc_driver::monitor::Sink as std::io::Write>::flush
  25: <rustc_driver::monitor::Sink as std::io::Write>::flush
  26: <rustc_driver::monitor::Sink as std::io::Write>::flush
  27: <rustc_driver::derive_registrar::Finder as rustc::hir::itemlikevisit::ItemLikeVisitor<'v>>::visit_impl_item
  28: rustc_driver::driver::compile_input
  29: rustc_driver::run_compiler
  30: <rustc_driver::pretty::UserIdentifiedItem as core::fmt::Debug>::fmt
  31: _rust_maybe_catch_panic
  32: <log::NopLogger as log::Log>::enabled
  33: std::sync::mpsc::sync::Queue::dequeue
  34: std::sys::windows::thread::Thread::new
  35: BaseThreadInitThunk

error: Could not compile `abi-test`.

Rust version:

rustc 1.25.0-nightly (ee220daca 2018-01-07)
binary: rustc
commit-hash: ee220daca345302c3277befee2732b6b2a5a711c
commit-date: 2018-01-07
host: x86_64-pc-windows-msvc
release: 1.25.0-nightly
LLVM version: 4.0

cc @eddyb

@nagisa nagisa added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ O-PowerPC Target: PowerPC processors labels Jan 9, 2018
@eddyb
Copy link
Member

eddyb commented Jan 12, 2018

Looks like this could be caused by this common skipping of padding arguments:

if arg.pad.is_some() {
llarg_idx += 1;
}

Combined with this store_fn_arg call (which internally also skips padding arguments):

arg.store_fn_arg(bcx, &mut llarg_idx, tmp);

When the latter gets used, each padding argument is skipped twice. I assume this is #45225 fallout.

@eddyb eddyb added the regression-from-stable-to-beta Performance or correctness regression from stable to beta. label Jan 12, 2018
@Mark-Simulacrum Mark-Simulacrum added this to the 1.24 milestone Jan 15, 2018
hanna-kruppe pushed a commit to hanna-kruppe/rust that referenced this issue Jan 16, 2018
@nikomatsakis
Copy link
Contributor

triage: P-high

Beta regression. Has pending fix.

@rust-highfive rust-highfive added the P-high High priority label Jan 18, 2018
bors added a commit that referenced this issue Jan 19, 2018
Compute LLVM argument indices correctly in face of padding

Closes #47278

r? @eddyb
MaloJaffre pushed a commit to MaloJaffre/rust that referenced this issue Jan 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ O-PowerPC Target: PowerPC processors P-high High priority regression-from-stable-to-beta Performance or correctness regression from stable to beta.
Projects
None yet
Development

No branches or pull requests

6 participants