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:
parent
9725c4baac
commit
0abecda9ed
3 changed files with 10 additions and 12 deletions
|
|
@ -48,6 +48,8 @@ use rustc_session::config::{OptLevel, OutputFilenames, PrintKind, PrintRequest};
|
|||
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 @@ impl ModuleLlvm {
|
|||
|
||||
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 @@ impl ModuleLlvm {
|
|||
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(crate) type GetSymbolsErrorCallback = unsafe extern "C" fn(*const c_char) ->
|
|||
|
||||
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 @@ unsafe extern "C" {
|
|||
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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue