mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Replace LLVMRustContextCreate with normal LLVM-C API calls
Since `LLVMRustContextCreate` can easily be replaced with a call to `LLVMContextCreate` and `LLVMContextSetDiscardValueNames`.
This commit is contained in:
@@ -48,6 +48,8 @@
|
||||
use rustc_span::Symbol;
|
||||
use rustc_target::spec::{RelocModel, TlsModel};
|
||||
|
||||
use crate::llvm::ToLlvmBool;
|
||||
|
||||
mod abi;
|
||||
mod allocator;
|
||||
mod asm;
|
||||
@@ -384,7 +386,8 @@ unsafe impl Sync for ModuleLlvm {}
|
||||
impl ModuleLlvm {
|
||||
fn new(tcx: TyCtxt<'_>, mod_name: &str) -> Self {
|
||||
unsafe {
|
||||
let llcx = llvm::LLVMRustContextCreate(tcx.sess.fewer_names());
|
||||
let llcx = llvm::LLVMContextCreate();
|
||||
llvm::LLVMContextSetDiscardValueNames(llcx, tcx.sess.fewer_names().to_llvm_bool());
|
||||
let llmod_raw = context::create_module(tcx, llcx, mod_name) as *const _;
|
||||
ModuleLlvm {
|
||||
llmod_raw,
|
||||
@@ -396,7 +399,8 @@ fn new(tcx: TyCtxt<'_>, mod_name: &str) -> Self {
|
||||
|
||||
fn new_metadata(tcx: TyCtxt<'_>, mod_name: &str) -> Self {
|
||||
unsafe {
|
||||
let llcx = llvm::LLVMRustContextCreate(tcx.sess.fewer_names());
|
||||
let llcx = llvm::LLVMContextCreate();
|
||||
llvm::LLVMContextSetDiscardValueNames(llcx, tcx.sess.fewer_names().to_llvm_bool());
|
||||
let llmod_raw = context::create_module(tcx, llcx, mod_name) as *const _;
|
||||
ModuleLlvm {
|
||||
llmod_raw,
|
||||
@@ -427,7 +431,8 @@ fn parse(
|
||||
dcx: DiagCtxtHandle<'_>,
|
||||
) -> Self {
|
||||
unsafe {
|
||||
let llcx = llvm::LLVMRustContextCreate(cgcx.fewer_names);
|
||||
let llcx = llvm::LLVMContextCreate();
|
||||
llvm::LLVMContextSetDiscardValueNames(llcx, cgcx.fewer_names.to_llvm_bool());
|
||||
let llmod_raw = back::lto::parse_module(llcx, name, buffer, dcx);
|
||||
let tm = ModuleLlvm::tm_from_cgcx(cgcx, name.to_str().unwrap(), dcx);
|
||||
|
||||
|
||||
@@ -905,7 +905,9 @@ pub struct GEPNoWrapFlags : c_uint {
|
||||
|
||||
unsafe extern "C" {
|
||||
// Create and destroy contexts.
|
||||
pub(crate) fn LLVMContextCreate() -> &'static mut Context;
|
||||
pub(crate) fn LLVMContextDispose(C: &'static mut Context);
|
||||
pub(crate) fn LLVMContextSetDiscardValueNames(C: &Context, Discard: Bool);
|
||||
pub(crate) fn LLVMGetMDKindIDInContext(
|
||||
C: &Context,
|
||||
Name: *const c_char,
|
||||
@@ -1925,9 +1927,6 @@ pub(crate) fn LLVMDIBuilderCreateParameterVariable<'ll>(
|
||||
pub(crate) fn LLVMRustInstallErrorHandlers();
|
||||
pub(crate) fn LLVMRustDisableSystemDialogsOnCrash();
|
||||
|
||||
// Create and destroy contexts.
|
||||
pub(crate) fn LLVMRustContextCreate(shouldDiscardNames: bool) -> &'static mut Context;
|
||||
|
||||
// Operations on all values
|
||||
pub(crate) fn LLVMRustGlobalAddMetadata<'a>(
|
||||
Val: &'a Value,
|
||||
|
||||
@@ -123,12 +123,6 @@ extern "C" void LLVMRustSetLastError(const char *Err) {
|
||||
LastError = strdup(Err);
|
||||
}
|
||||
|
||||
extern "C" LLVMContextRef LLVMRustContextCreate(bool shouldDiscardNames) {
|
||||
auto ctx = new LLVMContext();
|
||||
ctx->setDiscardValueNames(shouldDiscardNames);
|
||||
return wrap(ctx);
|
||||
}
|
||||
|
||||
extern "C" void LLVMRustSetNormalizedTarget(LLVMModuleRef M,
|
||||
const char *Target) {
|
||||
#if LLVM_VERSION_GE(21, 0)
|
||||
|
||||
Reference in New Issue
Block a user