Skip to content
Permalink
Browse files

rustc_target: add abi::call::Conv::Rust distinct from Conv::C.

  • Loading branch information
eddyb committed Nov 27, 2019
1 parent e93aa10 commit 79d908b301c4ad8b0778331af4b0c6ad46970ef1
@@ -2441,7 +2441,7 @@ where

use rustc_target::spec::abi::Abi::*;
let conv = match cx.tcx().sess.target.target.adjust_abi(sig.abi) {
RustIntrinsic | PlatformIntrinsic | Rust | RustCall => Conv::C,
RustIntrinsic | PlatformIntrinsic | Rust | RustCall => Conv::Rust,

// It's the ABI's job to select this, not ours.
System => bug!("system abi should be selected elsewhere"),
@@ -372,7 +372,7 @@ impl<'tcx> FnAbiLlvmExt<'tcx> for FnAbi<'tcx, Ty<'tcx>> {

fn llvm_cconv(&self) -> llvm::CallConv {
match self.conv {
Conv::C => llvm::CCallConv,
Conv::C | Conv::Rust => llvm::CCallConv,
Conv::AmdGpuKernel => llvm::AmdGpuKernel,
Conv::ArmAapcs => llvm::ArmAapcsCallConv,
Conv::Msp430Intr => llvm::Msp430Intr,
@@ -6,15 +6,16 @@ use rustc::hir::CodegenFnAttrFlags;
use rustc::hir::def_id::{DefId, LOCAL_CRATE};
use rustc::session::Session;
use rustc::session::config::{Sanitizer, OptLevel};
use rustc::ty::{self, TyCtxt};
use rustc::ty::{self, TyCtxt, Ty};
use rustc::ty::layout::HasTyCtxt;
use rustc::ty::query::Providers;
use rustc_data_structures::small_c_str::SmallCStr;
use rustc_data_structures::fx::FxHashMap;
use rustc_target::abi::call::Conv;
use rustc_target::spec::PanicStrategy;
use rustc_codegen_ssa::traits::*;

use crate::abi::Abi;
use crate::abi::FnAbi;
use crate::attributes;
use crate::llvm::{self, Attribute};
use crate::llvm::AttributePlace::Function;
@@ -203,6 +204,7 @@ pub fn from_fn_attrs(
cx: &CodegenCx<'ll, 'tcx>,
llfn: &'ll Value,
instance: ty::Instance<'tcx>,
fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
) {
let codegen_fn_attrs = cx.tcx.codegen_fn_attrs(instance.def_id());

@@ -279,10 +281,7 @@ pub fn from_fn_attrs(
// Special attribute for allocator functions, which can't unwind.
false
} else {
// FIXME(eddyb) avoid this `Instance::fn_sig` call.
// Perhaps store the relevant information in `FnAbi`?
let abi = instance.fn_sig(cx.tcx()).abi();
if abi == Abi::Rust || abi == Abi::RustCall {
if fn_abi.conv == Conv::Rust {
// Any Rust method (or `extern "Rust" fn` or `extern
// "rust-call" fn`) is explicitly allowed to unwind
// (unless it has no-unwind attribute, handled above).
@@ -80,7 +80,7 @@ pub fn get_fn(
let llfn = cx.declare_fn(&sym, &fn_abi);
debug!("get_fn: not casting pointer!");

attributes::from_fn_attrs(cx, llfn, instance);
attributes::from_fn_attrs(cx, llfn, instance, &fn_abi);

let instance_def_id = instance.def_id();

@@ -70,7 +70,7 @@ impl PreDefineMethods<'tcx> for CodegenCx<'ll, 'tcx> {

debug!("predefine_fn: instance = {:?}", instance);

attributes::from_fn_attrs(self, lldecl, instance);
attributes::from_fn_attrs(self, lldecl, instance, &fn_abi);

self.instances.borrow_mut().insert(instance, lldecl);
}
@@ -492,7 +492,12 @@ impl<'a, Ty> ArgAbi<'a, Ty> {

#[derive(Copy, Clone, PartialEq, Debug)]
pub enum Conv {
// General language calling conventions, for which every target
// should have its own backend (e.g. LLVM) support.
C,
Rust,

// Target-specific calling conventions.

ArmAapcs,

0 comments on commit 79d908b

Please sign in to comment.
You can’t perform that action at this time.