Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
3dd0a7d
Do not call `unwrap` with `signatures` option enabled
JohnTitor Oct 25, 2020
459dae9
fix #72680 by explicitly checking for or-pattern before test
mark-i-m Nov 7, 2020
43e4783
address reviewer comments
mark-i-m Nov 9, 2020
659aa77
test: add `()=()=()=...` to weird-exprs.rs
slanterns Nov 11, 2020
f5e67b5
Add a test for r# identifiers
poliorcetics Nov 12, 2020
9c70696
Ignore tidy linelength
poliorcetics Nov 12, 2020
bd0eb07
Added some unit tests as requested
richkadel Nov 3, 2020
ecfeac5
Use intradoc-links for the whole test, add a @has check
poliorcetics Nov 12, 2020
562d50e
Include llvm-as in llvm-tools-preview component
zec Nov 12, 2020
e4a43fc
Merge changes from rust-lang/rust
zec Nov 12, 2020
38fa66a
Rename empty_tuple_assignment to monkey_barrel
slanterns Nov 12, 2020
eb9f2bb
Overcome Sync issues with non-parallel compiler
richkadel Nov 12, 2020
775f1e5
fix pretty print for qpath
gui1117 Nov 12, 2020
f8a32e9
Bumped minimal tested LLVM version to 9
DevJPM Nov 7, 2020
6323565
explicitly add llvm-9-dev in dockerfile
DevJPM Nov 7, 2020
6830f1c
Bump the minimal supported LLVM version in the bootstrapping code to 9.0
DevJPM Nov 7, 2020
b51bcc7
fully exploited the dropped support of LLVM 8
DevJPM Nov 7, 2020
8236830
Removed an unused function now that LLVM 9 is the minimal supported v…
DevJPM Nov 7, 2020
7e443c4
Dropped Support for Bidirectional Custom Target Definition Emulation
DevJPM Nov 10, 2020
86193ca
fixed a re-format due to removed chain call
DevJPM Nov 10, 2020
3747df7
Avoid installing external LLVM dylibs
Mark-Simulacrum Nov 12, 2020
010265a
Fix an intrinsic invocation on threaded wasm
alexcrichton Nov 12, 2020
dd682cb
rustc_target: Fix dash vs underscore mismatches in option names
petrochenkov Nov 12, 2020
0b4af16
Never inline when `no_sanitize` attributes differ
tmiasko Nov 11, 2020
ae43326
Never inline cold functions
tmiasko Nov 11, 2020
9bb3d6b
Remove check for impossible condition
tmiasko Nov 11, 2020
66cadec
Fix generator inlining by checking for rust-call abi and spread arg
tmiasko Nov 11, 2020
79d853e
Never inline C variadic functions
tmiasko Nov 11, 2020
2a010dd
./x.py test --bless
tmiasko Nov 11, 2020
d486bfc
Normalize function type during validation
tmiasko Nov 12, 2020
99be78d
Always use param_env_reveal_all_normalized in validator
tmiasko Nov 12, 2020
cc6baf7
rustc_expand: Mark inner `#![test]` attributes as soft-unstable
petrochenkov Nov 12, 2020
016146d
Add column number support to Backtrace
est31 Nov 12, 2020
31741aa
Add `--color` support to bootstrap
jyn514 Nov 12, 2020
8766c04
cleanup: Remove `ParseSess::injected_crate_name`
petrochenkov Nov 12, 2020
c131063
Added a unit test for BcbCounters
richkadel Nov 13, 2020
309d863
Fix wrong XPath
poliorcetics Nov 13, 2020
894b1f7
extract closures into a separate trait
lcnr Nov 13, 2020
b4b0ef3
Addressed feedback
richkadel Nov 13, 2020
75dfc71
refactor: vec_deque ignore-tidy-filelength
DeveloperC286 Nov 13, 2020
bf6902c
Add BTreeMap::retain and BTreeSet::retain
mbrubeck Nov 13, 2020
7eb1a1a
Validate that locals have a corresponding `LocalDecl`
camelid Nov 13, 2020
ac4c1f5
rustc_resolve: Make `macro_rules` scope chain compression lazy
petrochenkov Nov 13, 2020
e7b6b61
Limit storage duration of inlined always live locals
tmiasko Nov 14, 2020
41c44b4
Move Steal to rustc_data_structures.
cjgillot Nov 14, 2020
03cbee8
Rename ItemEnum -> ItemKind, inner -> kind
jyn514 Nov 14, 2020
b825ae7
Style nit
mark-i-m Nov 14, 2020
8cf3564
Add underscore expressions for destructuring assignments
fanzier Nov 11, 2020
c6ef82e
Rollup merge of #78352 - JohnTitor:issue-75229, r=Dylan-DPC
jonas-schievink Nov 14, 2020
84322e0
Rollup merge of #78590 - DeveloperC286:issue_60302, r=varkor
jonas-schievink Nov 14, 2020
0501196
Rollup merge of #78848 - DevJPM:ci-llvm-9, r=nikic
jonas-schievink Nov 14, 2020
fd14608
Rollup merge of #78856 - mark-i-m:fix-or-pat-ice, r=matthewjasper
jonas-schievink Nov 14, 2020
d6fc536
Rollup merge of #78948 - slanterns:master, r=varkor
jonas-schievink Nov 14, 2020
a97a51e
Rollup merge of #78962 - poliorcetics:rustdoc-raw-ident-test, r=jyn514
jonas-schievink Nov 14, 2020
829b5ab
Rollup merge of #78963 - richkadel:llvm-coverage-counters-2.0.4, r=tm…
jonas-schievink Nov 14, 2020
da75594
Rollup merge of #78966 - tmiasko:inline-never, r=oli-obk
jonas-schievink Nov 14, 2020
c6ec024
Rollup merge of #78968 - zec:add-llvm-as, r=Mark-Simulacrum
jonas-schievink Nov 14, 2020
738883f
Rollup merge of #78969 - tmiasko:normalize, r=davidtwco
jonas-schievink Nov 14, 2020
7c8270b
Rollup merge of #78980 - thiolliere:gui-fix-qpath, r=estebank
jonas-schievink Nov 14, 2020
0938665
Rollup merge of #78986 - Mark-Simulacrum:fix-llvm, r=alexcrichton
jonas-schievink Nov 14, 2020
d6a6035
Rollup merge of #78988 - alexcrichton:one-more-intrinsic, r=sfackler
jonas-schievink Nov 14, 2020
9660e60
Rollup merge of #78993 - petrochenkov:specdash, r=oli-obk
jonas-schievink Nov 14, 2020
529cf6b
Rollup merge of #79002 - est31:backtrace_colno, r=dtolnay
jonas-schievink Nov 14, 2020
990d2b3
Rollup merge of #79003 - petrochenkov:innertest, r=estebank
jonas-schievink Nov 14, 2020
7e15e47
Rollup merge of #79004 - jyn514:bacon, r=Mark-Simulacrum
jonas-schievink Nov 14, 2020
656dca4
Rollup merge of #79005 - petrochenkov:noinjected, r=davidtwco
jonas-schievink Nov 14, 2020
8998722
Rollup merge of #79016 - fanzier:underscore-expressions, r=petrochenkov
jonas-schievink Nov 14, 2020
4f3d33c
Rollup merge of #79019 - lcnr:generic-arg-validation, r=petrochenkov
jonas-schievink Nov 14, 2020
5d81b56
Rollup merge of #79026 - mbrubeck:btree_retain, r=m-ou-se
jonas-schievink Nov 14, 2020
a1d5cb3
Rollup merge of #79027 - tmiasko:inline-always-live-locals, r=oli-obk
jonas-schievink Nov 14, 2020
a296c26
Rollup merge of #79031 - camelid:mir-validate-local-decl, r=jonas-sch…
jonas-schievink Nov 14, 2020
129fe1e
Rollup merge of #79034 - petrochenkov:mrscopes3, r=eddyb
jonas-schievink Nov 14, 2020
35d2973
Rollup merge of #79036 - cjgillot:steal, r=oli-obk
jonas-schievink Nov 14, 2020
757443a
Rollup merge of #79041 - jyn514:inner-to-kind, r=petrochenkov
jonas-schievink Nov 14, 2020
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
Prev Previous commit
Next Next commit
Fix generator inlining by checking for rust-call abi and spread arg
  • Loading branch information
tmiasko committed Nov 12, 2020
commit 66cadec1763ac645337c1ac58f06ea48b9b72a26
26 changes: 14 additions & 12 deletions compiler/rustc_mir/src/transform/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use rustc_index::vec::Idx;
use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs};
use rustc_middle::mir::visit::*;
use rustc_middle::mir::*;
use rustc_middle::ty::subst::Subst;
use rustc_middle::ty::{self, ConstKind, Instance, InstanceDef, ParamEnv, Ty, TyCtxt};
use rustc_span::{hygiene::ExpnKind, ExpnData, Span};
use rustc_target::spec::abi::Abi;
Expand All @@ -28,6 +29,7 @@ pub struct Inline;
#[derive(Copy, Clone, Debug)]
struct CallSite<'tcx> {
callee: Instance<'tcx>,
fn_sig: ty::PolyFnSig<'tcx>,
block: BasicBlock,
target: Option<BasicBlock>,
source_info: SourceInfo,
Expand Down Expand Up @@ -173,22 +175,23 @@ impl Inliner<'tcx> {

// Only consider direct calls to functions
let terminator = bb_data.terminator();
if let TerminatorKind::Call { func: ref op, ref destination, .. } = terminator.kind {
if let ty::FnDef(callee_def_id, substs) = *op.ty(caller_body, self.tcx).kind() {
// To resolve an instance its substs have to be fully normalized, so
// we do this here.
let normalized_substs = self.tcx.normalize_erasing_regions(self.param_env, substs);
if let TerminatorKind::Call { ref func, ref destination, .. } = terminator.kind {
let func_ty = func.ty(caller_body, self.tcx);
if let ty::FnDef(def_id, substs) = *func_ty.kind() {
// To resolve an instance its substs have to be fully normalized.
let substs = self.tcx.normalize_erasing_regions(self.param_env, substs);
let callee =
Instance::resolve(self.tcx, self.param_env, callee_def_id, normalized_substs)
.ok()
.flatten()?;
Instance::resolve(self.tcx, self.param_env, def_id, substs).ok().flatten()?;

if let InstanceDef::Virtual(..) | InstanceDef::Intrinsic(_) = callee.def {
return None;
}

let fn_sig = self.tcx.fn_sig(def_id).subst(self.tcx, substs);

return Some(CallSite {
callee,
fn_sig,
block: bb,
target: destination.map(|(_, target)| target),
source_info: terminator.source_info,
Expand Down Expand Up @@ -437,7 +440,7 @@ impl Inliner<'tcx> {
};

// Copy the arguments if needed.
let args: Vec<_> = self.make_call_args(args, &callsite, caller_body);
let args: Vec<_> = self.make_call_args(args, &callsite, caller_body, &callee_body);

let mut integrator = Integrator {
args: &args,
Expand Down Expand Up @@ -518,6 +521,7 @@ impl Inliner<'tcx> {
args: Vec<Operand<'tcx>>,
callsite: &CallSite<'tcx>,
caller_body: &mut Body<'tcx>,
callee_body: &Body<'tcx>,
) -> Vec<Local> {
let tcx = self.tcx;

Expand All @@ -544,9 +548,7 @@ impl Inliner<'tcx> {
// tmp2 = tuple_tmp.2
//
// and the vector is `[closure_ref, tmp0, tmp1, tmp2]`.
// FIXME(eddyb) make this check for `"rust-call"` ABI combined with
// `callee_body.spread_arg == None`, instead of special-casing closures.
if tcx.is_closure(callsite.callee.def_id()) {
if callsite.fn_sig.abi() == Abi::RustCall && callee_body.spread_arg.is_none() {
let mut args = args.into_iter();
let self_ = self.create_temp_if_necessary(args.next().unwrap(), callsite, caller_body);
let tuple = self.create_temp_if_necessary(args.next().unwrap(), callsite, caller_body);
Expand Down
16 changes: 16 additions & 0 deletions src/test/mir-opt/inline/inline-generator.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// ignore-wasm32-bare compiled with panic=abort by default
#![feature(generators, generator_trait)]

use std::ops::Generator;
use std::pin::Pin;

// EMIT_MIR inline_generator.main.Inline.diff
fn main() {
let _r = Pin::new(&mut g()).resume(false);
}

#[inline(always)]
pub fn g() -> impl Generator<bool> {
#[inline(always)]
|a| { yield if a { 7 } else { 13 } }
}