Fix warnings about the native
target-cpu
This fixes a regression from #53031 where specifying `-C target-cpu=native` is printing a lot of warnings from LLVM about `native` being an unknown CPU. It turns out that `native` is indeed an unknown CPU and we have to perform a mapping to an actual CPU name, but this mapping is only performed in one location rather than all locations we inform LLVM about the target CPU. This commit centralizes the mapping of `native` to LLVM's value of the native CPU, ensuring that all locations we inform LLVM about the `target-cpu` it's never `native`. Closes #53322
This commit is contained in:
parent
7061b27757
commit
1fd45a13de
8 changed files with 49 additions and 18 deletions
|
@ -124,7 +124,8 @@ pub fn llvm_target_features(sess: &Session) -> impl Iterator<Item = &str> {
|
|||
}
|
||||
|
||||
pub fn apply_target_cpu_attr(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
|
||||
let target_cpu = CString::new(cx.tcx.sess.target_cpu().to_string()).unwrap();
|
||||
let cpu = llvm_util::target_cpu(cx.tcx.sess);
|
||||
let target_cpu = CString::new(cpu).unwrap();
|
||||
llvm::AddFunctionAttrStringValue(
|
||||
llfn,
|
||||
llvm::AttributePlace::Function,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue