Merge commit '08a6d6e16b
' into sync-cg_gcc-2023-03-04
This commit is contained in:
commit
6bb2af0e6d
61 changed files with 5730 additions and 1123 deletions
|
@ -8,6 +8,8 @@ use gccjit::{
|
|||
};
|
||||
use rustc_middle::dep_graph;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
#[cfg(feature="master")]
|
||||
use rustc_middle::mir::mono::Visibility;
|
||||
use rustc_middle::mir::mono::Linkage;
|
||||
use rustc_codegen_ssa::{ModuleCodegen, ModuleKind};
|
||||
use rustc_codegen_ssa::base::maybe_create_entry_wrapper;
|
||||
|
@ -20,6 +22,15 @@ use crate::GccContext;
|
|||
use crate::builder::Builder;
|
||||
use crate::context::CodegenCx;
|
||||
|
||||
#[cfg(feature="master")]
|
||||
pub fn visibility_to_gcc(linkage: Visibility) -> gccjit::Visibility {
|
||||
match linkage {
|
||||
Visibility::Default => gccjit::Visibility::Default,
|
||||
Visibility::Hidden => gccjit::Visibility::Hidden,
|
||||
Visibility::Protected => gccjit::Visibility::Protected,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn global_linkage_to_gcc(linkage: Linkage) -> GlobalKind {
|
||||
match linkage {
|
||||
Linkage::External => GlobalKind::Imported,
|
||||
|
@ -76,16 +87,34 @@ pub fn compile_codegen_unit(tcx: TyCtxt<'_>, cgu_name: Symbol, supports_128bit_i
|
|||
// Instantiate monomorphizations without filling out definitions yet...
|
||||
//let llvm_module = ModuleLlvm::new(tcx, &cgu_name.as_str());
|
||||
let context = Context::default();
|
||||
|
||||
context.add_command_line_option("-fexceptions");
|
||||
context.add_driver_option("-fexceptions");
|
||||
|
||||
// TODO(antoyo): only set on x86 platforms.
|
||||
context.add_command_line_option("-masm=intel");
|
||||
// TODO(antoyo): only add the following cli argument if the feature is supported.
|
||||
context.add_command_line_option("-msse2");
|
||||
context.add_command_line_option("-mavx2");
|
||||
context.add_command_line_option("-msha");
|
||||
context.add_command_line_option("-mpclmul");
|
||||
// FIXME(antoyo): the following causes an illegal instruction on vmovdqu64 in std_example on my CPU.
|
||||
// Only add if the CPU supports it.
|
||||
//context.add_command_line_option("-mavx512f");
|
||||
context.add_command_line_option("-msha");
|
||||
context.add_command_line_option("-mpclmul");
|
||||
context.add_command_line_option("-mfma");
|
||||
context.add_command_line_option("-mfma4");
|
||||
context.add_command_line_option("-m64");
|
||||
context.add_command_line_option("-mbmi");
|
||||
context.add_command_line_option("-mgfni");
|
||||
//context.add_command_line_option("-mavxvnni"); // The CI doesn't support this option.
|
||||
context.add_command_line_option("-mf16c");
|
||||
context.add_command_line_option("-maes");
|
||||
context.add_command_line_option("-mxsavec");
|
||||
context.add_command_line_option("-mbmi2");
|
||||
context.add_command_line_option("-mrtm");
|
||||
context.add_command_line_option("-mvaes");
|
||||
context.add_command_line_option("-mvpclmulqdq");
|
||||
context.add_command_line_option("-mavx");
|
||||
|
||||
for arg in &tcx.sess.opts.cg.llvm_args {
|
||||
context.add_command_line_option(arg);
|
||||
}
|
||||
|
@ -95,12 +124,20 @@ pub fn compile_codegen_unit(tcx: TyCtxt<'_>, cgu_name: Symbol, supports_128bit_i
|
|||
context.add_command_line_option("-fno-semantic-interposition");
|
||||
// NOTE: Rust relies on LLVM not doing TBAA (https://github.com/rust-lang/unsafe-code-guidelines/issues/292).
|
||||
context.add_command_line_option("-fno-strict-aliasing");
|
||||
// NOTE: Rust relies on LLVM doing wrapping on overflow.
|
||||
context.add_command_line_option("-fwrapv");
|
||||
|
||||
if tcx.sess.opts.unstable_opts.function_sections.unwrap_or(tcx.sess.target.function_sections) {
|
||||
context.add_command_line_option("-ffunction-sections");
|
||||
context.add_command_line_option("-fdata-sections");
|
||||
}
|
||||
|
||||
if env::var("CG_GCCJIT_DUMP_RTL").as_deref() == Ok("1") {
|
||||
context.add_command_line_option("-fdump-rtl-vregs");
|
||||
}
|
||||
if env::var("CG_GCCJIT_DUMP_TREE_ALL").as_deref() == Ok("1") {
|
||||
context.add_command_line_option("-fdump-tree-all");
|
||||
}
|
||||
if env::var("CG_GCCJIT_DUMP_CODE").as_deref() == Ok("1") {
|
||||
context.set_dump_code_on_compile(true);
|
||||
}
|
||||
|
@ -115,7 +152,7 @@ pub fn compile_codegen_unit(tcx: TyCtxt<'_>, cgu_name: Symbol, supports_128bit_i
|
|||
context.set_keep_intermediates(true);
|
||||
}
|
||||
|
||||
// TODO(bjorn3): Remove once unwinding is properly implemented
|
||||
// NOTE: The codegen generates unrechable blocks.
|
||||
context.set_allow_unreachable_blocks(true);
|
||||
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue