Skip to content

Commit 7b3150e

Browse files
jdonszelmannbjorn3
authored andcommitted
add aliasses to llvm
1 parent 68ac5ab commit 7b3150e

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2670,4 +2670,12 @@ unsafe extern "C" {
26702670

26712671
pub(crate) fn LLVMRustSetNoSanitizeAddress(Global: &Value);
26722672
pub(crate) fn LLVMRustSetNoSanitizeHWAddress(Global: &Value);
2673+
2674+
pub(crate) fn LLVMAddAlias2(
2675+
M: &Module,
2676+
ValueTy: &Type,
2677+
AddressSpace: c_uint,
2678+
Aliasee: &Value,
2679+
Name: *const c_char,
2680+
);
26732681
}

compiler/rustc_codegen_llvm/src/llvm/mod.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::str::FromStr;
77
use std::string::FromUtf8Error;
88

99
use libc::c_uint;
10-
use rustc_abi::{Align, Size, WrappingRange};
10+
use rustc_abi::{AddressSpace, Align, Size, WrappingRange};
1111
use rustc_llvm::RustString;
1212

1313
pub(crate) use self::CallConv::*;
@@ -350,6 +350,20 @@ impl Intrinsic {
350350
}
351351
}
352352

353+
/// Safe wrapper for `LLVMAddAlias2`
354+
pub(crate) fn add_alias(
355+
module: &Module,
356+
ty: &Type,
357+
address_space: AddressSpace,
358+
aliasee: &Value,
359+
name: &[u8],
360+
) {
361+
unsafe {
362+
let data = name.as_c_char_ptr();
363+
LLVMAddAlias2(value, data, address_space, aliasee, name.len());
364+
}
365+
}
366+
353367
/// Safe wrapper for `LLVMSetValueName2` from a byte slice
354368
pub(crate) fn set_value_name(value: &Value, name: &[u8]) {
355369
unsafe {

0 commit comments

Comments
 (0)