use crate::type_::Type;
use crate::value::Value;
use log::debug;
-use rustc::session::config::Sanitizer;
use rustc::ty::Ty;
use rustc_codegen_ssa::traits::*;
-use rustc_data_structures::small_c_str::SmallCStr;
/// Declare a function.
///
ty: &'ll Type,
) -> &'ll Value {
debug!("declare_raw_fn(name={:?}, ty={:?})", name, ty);
- let namebuf = SmallCStr::new(name);
- let llfn = unsafe { llvm::LLVMRustGetOrInsertFunction(cx.llmod, namebuf.as_ptr(), ty) };
+ let llfn = unsafe {
+ llvm::LLVMRustGetOrInsertFunction(cx.llmod, name.as_ptr().cast(), name.len(), ty)
+ };
llvm::SetFunctionCallConv(llfn, callconv);
// Function addresses in Rust are never significant, allowing functions to
llvm::Attribute::NoRedZone.apply_llfn(Function, llfn);
}
- if let Some(ref sanitizer) = cx.tcx.sess.opts.debugging_opts.sanitizer {
- match *sanitizer {
- Sanitizer::Address => {
- llvm::Attribute::SanitizeAddress.apply_llfn(Function, llfn);
- }
- Sanitizer::Memory => {
- llvm::Attribute::SanitizeMemory.apply_llfn(Function, llfn);
- }
- Sanitizer::Thread => {
- llvm::Attribute::SanitizeThread.apply_llfn(Function, llfn);
- }
- _ => {}
- }
- }
-
attributes::default_optimisation_attrs(cx.tcx.sess, llfn);
attributes::non_lazy_bind(cx.sess(), llfn);
llfn
fn get_declared_value(&self, name: &str) -> Option<&'ll Value> {
debug!("get_declared_value(name={:?})", name);
- let namebuf = SmallCStr::new(name);
- unsafe { llvm::LLVMRustGetNamedValue(self.llmod, namebuf.as_ptr()) }
+ unsafe { llvm::LLVMRustGetNamedValue(self.llmod, name.as_ptr().cast(), name.len()) }
}
fn get_defined_value(&self, name: &str) -> Option<&'ll Value> {