Rollup merge of #117141 - tmiasko:inline-target-features, r=oli-obk

Require target features to match exactly during inlining

In general it is not correct to inline a callee with a target features
that are subset of the callee. Require target features to match exactly
during inlining.

The exact match could be potentially relaxed, but this would require
identifying specific feature that are allowed to differ, those that need
to match, and those that can be present in caller but not in callee.

This resolves MIR part of #116573. For other concerns with respect to
the previous implementation also see areInlineCompatible in LLVM.
This commit is contained in:
Matthias Krüger 2023-10-25 19:51:14 +02:00 committed by GitHub
commit a1ab16792b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 52 additions and 238 deletions

View file

@ -438,10 +438,8 @@ impl<'tcx> Inliner<'tcx> {
return Err("incompatible instruction set");
}
for feature in &callee_attrs.target_features {
if !self.codegen_fn_attrs.target_features.contains(feature) {
return Err("incompatible target feature");
}
if callee_attrs.target_features != self.codegen_fn_attrs.target_features {
return Err("incompatible target features");
}
Ok(())