Merge pull request #211 from rust-lang/fix/used-function-attribute-inline-asm
Add used function attribute from inline asm
This commit is contained in:
commit
06b6ec0ebe
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -41,7 +41,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "gccjit"
|
name = "gccjit"
|
||||||
version = "1.0.0"
|
version = "1.0.0"
|
||||||
source = "git+https://github.com/antoyo/gccjit.rs#1a60fe3918a5b3b0983c1ea09f4b9445001a6468"
|
source = "git+https://github.com/antoyo/gccjit.rs#f30cc2bd330f4fda3d625f305bdfd7e523e2d8f8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"gccjit_sys",
|
"gccjit_sys",
|
||||||
]
|
]
|
||||||
@ -49,7 +49,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "gccjit_sys"
|
name = "gccjit_sys"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
source = "git+https://github.com/antoyo/gccjit.rs#1a60fe3918a5b3b0983c1ea09f4b9445001a6468"
|
source = "git+https://github.com/antoyo/gccjit.rs#f30cc2bd330f4fda3d625f305bdfd7e523e2d8f8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc 0.1.12",
|
"libc 0.1.12",
|
||||||
]
|
]
|
||||||
|
@ -718,6 +718,8 @@ fn codegen_global_asm(&self, template: &[InlineAsmTemplatePiece], operands: &[Gl
|
|||||||
}
|
}
|
||||||
|
|
||||||
GlobalAsmOperandRef::SymFn { instance } => {
|
GlobalAsmOperandRef::SymFn { instance } => {
|
||||||
|
let function = self.rvalue_as_function(get_fn(self, instance));
|
||||||
|
self.add_used_function(function);
|
||||||
// TODO(@Amanieu): Additional mangling is needed on
|
// TODO(@Amanieu): Additional mangling is needed on
|
||||||
// some targets to add a leading underscore (Mach-O)
|
// some targets to add a leading underscore (Mach-O)
|
||||||
// or byte count suffixes (x86 Windows).
|
// or byte count suffixes (x86 Windows).
|
||||||
@ -726,6 +728,7 @@ fn codegen_global_asm(&self, template: &[InlineAsmTemplatePiece], operands: &[Gl
|
|||||||
}
|
}
|
||||||
|
|
||||||
GlobalAsmOperandRef::SymStatic { def_id } => {
|
GlobalAsmOperandRef::SymStatic { def_id } => {
|
||||||
|
// TODO(antoyo): set the global variable as used.
|
||||||
// TODO(@Amanieu): Additional mangling is needed on
|
// TODO(@Amanieu): Additional mangling is needed on
|
||||||
// some targets to add a leading underscore (Mach-O).
|
// some targets to add a leading underscore (Mach-O).
|
||||||
let instance = Instance::mono(self.tcx, def_id);
|
let instance = Instance::mono(self.tcx, def_id);
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
use gccjit::{GlobalKind, LValue, RValue, ToRValue, Type};
|
#[cfg(feature = "master")]
|
||||||
|
use gccjit::FnAttribute;
|
||||||
|
use gccjit::{Function, GlobalKind, LValue, RValue, ToRValue, Type};
|
||||||
use rustc_codegen_ssa::traits::{BaseTypeMethods, ConstMethods, DerivedTypeMethods, StaticMethods};
|
use rustc_codegen_ssa::traits::{BaseTypeMethods, ConstMethods, DerivedTypeMethods, StaticMethods};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::Node;
|
use rustc_hir::Node;
|
||||||
@ -159,12 +161,19 @@ fn add_used_global(&self, _global: RValue<'gcc>) {
|
|||||||
// TODO(antoyo)
|
// TODO(antoyo)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_compiler_used_global(&self, _global: RValue<'gcc>) {
|
fn add_compiler_used_global(&self, global: RValue<'gcc>) {
|
||||||
// TODO(antoyo)
|
// NOTE: seems like GCC does not make the distinction between compiler.used and used.
|
||||||
|
self.add_used_global(global);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
|
impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
|
||||||
|
#[cfg_attr(not(feature="master"), allow(unused_variables))]
|
||||||
|
pub fn add_used_function(&self, function: Function<'gcc>) {
|
||||||
|
#[cfg(feature = "master")]
|
||||||
|
function.add_attribute(FnAttribute::Used);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn static_addr_of_mut(&self, cv: RValue<'gcc>, align: Align, kind: Option<&str>) -> RValue<'gcc> {
|
pub fn static_addr_of_mut(&self, cv: RValue<'gcc>, align: Align, kind: Option<&str>) -> RValue<'gcc> {
|
||||||
let global =
|
let global =
|
||||||
match kind {
|
match kind {
|
||||||
|
Loading…
Reference in New Issue
Block a user