about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/llvm/mod.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-06-16 03:40:18 +0000
committerbors <bors@rust-lang.org>2025-06-16 03:40:18 +0000
commit68ac5abb067806a88464ddbfbd3c7eec877b488d (patch)
tree0c7546d21adcf285dd5c975c7bf6e2811739b2b0 /compiler/rustc_codegen_llvm/src/llvm/mod.rs
parente314b97ee54091b6bcf33db4770c93d82fded8bc (diff)
parenta9500d6b0b1a97513f79ed8e04b07c5a4f4fc258 (diff)
downloadrust-68ac5abb067806a88464ddbfbd3c7eec877b488d.tar.gz
rust-68ac5abb067806a88464ddbfbd3c7eec877b488d.zip
Auto merge of #142521 - sayantn:simplify-intrinsics, r=nikic,workingjubilee
Use `LLVMIntrinsicGetDeclaration` to completely remove the hardcoded intrinsics list

Follow-up to rust-lang/rust#142259

This also needs a rustc-perf run, because `Intrinsic::getType` can be expensive

`@rustbot` label A-LLVM A-codegen T-compiler
r? `@workingjubilee`
cc `@nikic`
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/llvm/mod.rs')
-rw-r--r--compiler/rustc_codegen_llvm/src/llvm/mod.rs28
1 files changed, 4 insertions, 24 deletions
diff --git a/compiler/rustc_codegen_llvm/src/llvm/mod.rs b/compiler/rustc_codegen_llvm/src/llvm/mod.rs
index bc3538c768d..661174a80df 100644
--- a/compiler/rustc_codegen_llvm/src/llvm/mod.rs
+++ b/compiler/rustc_codegen_llvm/src/llvm/mod.rs
@@ -2,9 +2,9 @@
 
 use std::ffi::{CStr, CString};
 use std::num::NonZero;
+use std::ptr;
 use std::str::FromStr;
 use std::string::FromUtf8Error;
-use std::{ptr, slice};
 
 use libc::c_uint;
 use rustc_abi::{Align, Size, WrappingRange};
@@ -339,34 +339,14 @@ impl Intrinsic {
         NonZero::new(id).map(|id| Self { id })
     }
 
-    pub(crate) fn is_overloaded(self) -> bool {
-        unsafe { LLVMIntrinsicIsOverloaded(self.id) == True }
-    }
-
-    pub(crate) fn overloaded_name<'ll>(
+    pub(crate) fn get_declaration<'ll>(
         self,
         llmod: &'ll Module,
         type_params: &[&'ll Type],
-    ) -> String {
-        let mut len = 0;
-        let ptr = unsafe {
-            LLVMIntrinsicCopyOverloadedName2(
-                llmod,
-                self.id,
-                type_params.as_ptr(),
-                type_params.len(),
-                &mut len,
-            )
-        };
-
-        let slice = unsafe { slice::from_raw_parts_mut(ptr.cast(), len) };
-        let copied = str::from_utf8(slice).expect("Non-UTF8 intrinsic name").to_string();
-
+    ) -> &'ll Value {
         unsafe {
-            libc::free(ptr.cast());
+            LLVMGetIntrinsicDeclaration(llmod, self.id, type_params.as_ptr(), type_params.len())
         }
-
-        copied
     }
 }