diff options
| author | bors <bors@rust-lang.org> | 2022-11-26 12:11:32 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-11-26 12:11:32 +0000 |
| commit | 579c993b35a02dc439b74bba18b0a14f77911c95 (patch) | |
| tree | 96295864ecfb4bc5263a954f91f8ac4e2e6b3adb /compiler/rustc_mir_transform/src | |
| parent | 8841bee954ecf0e6820c9990feb3a76cb04e7d96 (diff) | |
| parent | 1fe18a5dad0efde1d4dd31afd49fc60f21d3f993 (diff) | |
| download | rust-579c993b35a02dc439b74bba18b0a14f77911c95.tar.gz rust-579c993b35a02dc439b74bba18b0a14f77911c95.zip | |
Auto merge of #104935 - matthiaskrgr:rollup-nuca86l, r=matthiaskrgr
Rollup of 6 pull requests
Successful merges:
- #104121 (Refine `instruction_set` MIR inline rules)
- #104675 (Unsupported query error now specifies if its unsupported for local or external crate)
- #104839 (improve array_from_fn documenation)
- #104880 ([llvm-wrapper] adapt for LLVM API change)
- #104899 (rustdoc: remove no-op CSS `#help dt { display: block }`)
- #104906 (Remove AscribeUserTypeCx)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_mir_transform/src')
| -rw-r--r-- | compiler/rustc_mir_transform/src/inline.rs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/compiler/rustc_mir_transform/src/inline.rs b/compiler/rustc_mir_transform/src/inline.rs index d7dd5fc8528..9174f04887e 100644 --- a/compiler/rustc_mir_transform/src/inline.rs +++ b/compiler/rustc_mir_transform/src/inline.rs @@ -375,7 +375,12 @@ impl<'tcx> Inliner<'tcx> { return Err("incompatible sanitizer set"); } - if callee_attrs.instruction_set != self.codegen_fn_attrs.instruction_set { + // Two functions are compatible if the callee has no attribute (meaning + // that it's codegen agnostic), or sets an attribute that is identical + // to this function's attribute. + if callee_attrs.instruction_set.is_some() + && callee_attrs.instruction_set != self.codegen_fn_attrs.instruction_set + { return Err("incompatible instruction set"); } @@ -453,6 +458,15 @@ impl<'tcx> Inliner<'tcx> { if ty.needs_drop(tcx, self.param_env) && let Some(unwind) = unwind { work_list.push(unwind); } + } else if callee_attrs.instruction_set != self.codegen_fn_attrs.instruction_set + && matches!(term.kind, TerminatorKind::InlineAsm { .. }) + { + // During the attribute checking stage we allow a callee with no + // instruction_set assigned to count as compatible with a function that does + // assign one. However, during this stage we require an exact match when any + // inline-asm is detected. LLVM will still possibly do an inline later on + // if the no-attribute function ends up with the same instruction set anyway. + return Err("Cannot move inline-asm across instruction sets"); } else { work_list.extend(term.successors()) } |
