Skip to content
This repository was archived by the owner on Jan 7, 2022. It is now read-only.

Commit 579fb1d

Browse files
bors[bot]vext01
andcommitted
Merge #9
9: The beginnings of a new "TIR" serialiser. r=ltratt a=vext01 This replaces the custom MIR serialiser, which a serde-based TIR (tracing IR) serialiser. The change of name is to signify that we are actually implementing our own IR now, not just a mirror of MIR. The conversion uses a trait `ToPack` which is effectively a poor man's `From` trait. We couldn't use the `From` trait since the "from" and "to" data structures are both external crates in the eyes of the compiler, and Rust currently disallows this. While we are here, remove the "YK_DEBUG_SECTIONS" environment variable switch, as we are always going to need this information. It's not just a debugging aid. We do not yet implement MIR to TIR statement translation. This will be started in my next PR. I plan to rename the file `mir_cfg.rs` to something more appropriate later (say `gen_tir.rs`), but only once my outstanding branches have been merged. Co-authored-by: Edd Barrett <vext01@gmail.com>
2 parents 3e38ccc + 81b1d97 commit 579fb1d

File tree

13 files changed

+195
-203
lines changed

13 files changed

+195
-203
lines changed

Cargo.lock

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,11 @@ name = "fake-simd"
853853
version = "0.1.2"
854854
source = "registry+https://github.com/rust-lang/crates.io-index"
855855

856+
[[package]]
857+
name = "fallible-iterator"
858+
version = "0.1.6"
859+
source = "registry+https://github.com/rust-lang/crates.io-index"
860+
856861
[[package]]
857862
name = "filetime"
858863
version = "0.2.4"
@@ -1644,6 +1649,14 @@ dependencies = [
16441649
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
16451650
]
16461651

1652+
[[package]]
1653+
name = "num-traits"
1654+
version = "0.1.43"
1655+
source = "registry+https://github.com/rust-lang/crates.io-index"
1656+
dependencies = [
1657+
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
1658+
]
1659+
16471660
[[package]]
16481661
name = "num-traits"
16491662
version = "0.2.6"
@@ -2333,6 +2346,25 @@ dependencies = [
23332346
"rls-span 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
23342347
]
23352348

2349+
[[package]]
2350+
name = "rmp"
2351+
version = "0.8.7"
2352+
source = "git+https://github.com/3Hren/msgpack-rust?rev=40b3d480b20961e6eeceb416b32bcd0a3383846a#40b3d480b20961e6eeceb416b32bcd0a3383846a"
2353+
dependencies = [
2354+
"byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
2355+
"num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)",
2356+
]
2357+
2358+
[[package]]
2359+
name = "rmp-serde"
2360+
version = "0.14.0"
2361+
source = "git+https://github.com/3Hren/msgpack-rust?rev=40b3d480b20961e6eeceb416b32bcd0a3383846a#40b3d480b20961e6eeceb416b32bcd0a3383846a"
2362+
dependencies = [
2363+
"byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
2364+
"rmp 0.8.7 (git+https://github.com/3Hren/msgpack-rust?rev=40b3d480b20961e6eeceb416b32bcd0a3383846a)",
2365+
"serde 1.0.82 (registry+https://github.com/rust-lang/crates.io-index)",
2366+
]
2367+
23362368
[[package]]
23372369
name = "rustbook"
23382370
version = "0.1.0"
@@ -2508,6 +2540,7 @@ dependencies = [
25082540
"rustc_codegen_ssa 0.0.0",
25092541
"rustc_driver 0.0.0",
25102542
"rustc_target 0.0.0",
2543+
"unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
25112544
]
25122545

25132546
[[package]]
@@ -2615,7 +2648,6 @@ dependencies = [
26152648
"num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
26162649
"rustc-demangle 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
26172650
"rustc_llvm 0.0.0",
2618-
"rustc_yk_sections 0.0.0",
26192651
]
26202652

26212653
[[package]]
@@ -2719,8 +2751,6 @@ dependencies = [
27192751
"rustc_target 0.0.0",
27202752
"rustc_traits 0.0.0",
27212753
"rustc_typeck 0.0.0",
2722-
"rustc_yk_link 0.0.0",
2723-
"rustc_yk_sections 0.0.0",
27242754
"scoped-tls 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
27252755
"serialize 0.0.0",
27262756
"smallvec 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2784,7 +2814,6 @@ dependencies = [
27842814
"rustc_resolve 0.0.0",
27852815
"rustc_traits 0.0.0",
27862816
"rustc_typeck 0.0.0",
2787-
"rustc_yk_link 0.0.0",
27882817
"rustc_yk_sections 0.0.0",
27892818
"scoped-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
27902819
"serialize 0.0.0",
@@ -3033,10 +3062,10 @@ version = "0.0.0"
30333062
name = "rustc_yk_sections"
30343063
version = "0.0.0"
30353064
dependencies = [
3036-
"byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
30373065
"rustc 0.0.0",
30383066
"rustc_codegen_utils 0.0.0",
30393067
"rustc_yk_link 0.0.0",
3068+
"ykpack 0.1.0 (git+https://github.com/softdevteam/ykpack)",
30403069
]
30413070

30423071
[[package]]
@@ -4012,6 +4041,16 @@ name = "yaml-rust"
40124041
version = "0.3.5"
40134042
source = "registry+https://github.com/rust-lang/crates.io-index"
40144043

4044+
[[package]]
4045+
name = "ykpack"
4046+
version = "0.1.0"
4047+
source = "git+https://github.com/softdevteam/ykpack#e0fd6162b9522fd04b6bbb77a232986c4ea5c257"
4048+
dependencies = [
4049+
"fallible-iterator 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
4050+
"rmp-serde 0.14.0 (git+https://github.com/3Hren/msgpack-rust?rev=40b3d480b20961e6eeceb416b32bcd0a3383846a)",
4051+
"serde 1.0.82 (registry+https://github.com/rust-lang/crates.io-index)",
4052+
]
4053+
40154054
[metadata]
40164055
"checksum adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7e522997b529f05601e05166c07ed17789691f562762c7f3b987263d2dedee5c"
40174056
"checksum aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9a933f4e58658d7b12defcf96dc5c720f20832deebe3e0a19efd3b6aaeeb9e"
@@ -4086,6 +4125,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
40864125
"checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2"
40874126
"checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1"
40884127
"checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
4128+
"checksum fallible-iterator 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "eb7217124812dc5672b7476d0c2d20cfe9f7c0f1ba0904b674a9762a0212f72e"
40894129
"checksum filetime 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a2df5c1a8c4be27e7707789dc42ae65976e60b394afd293d1419ab915833e646"
40904130
"checksum fixedbitset 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33"
40914131
"checksum flate2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2291c165c8e703ee54ef3055ad6188e3d51108e2ded18e9f2476e774fc5ad3d4"
@@ -4166,6 +4206,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
41664206
"checksum nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "9a2228dca57108069a5262f2ed8bd2e82496d2e074a06d1ccc7ce1687b6ae0a2"
41674207
"checksum num-derive 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8af1847c907c2f04d7bfd572fb25bbb4385c637fe5be163cf2f8c5d778fe1e7d"
41684208
"checksum num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "e83d528d2677f0518c570baf2b7abdcf0cd2d248860b68507bdcb3e91d4c0cea"
4209+
"checksum num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31"
41694210
"checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1"
41704211
"checksum num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c51a3322e4bca9d212ad9a158a02abc6934d005490c054a2778df73a70aa0a30"
41714212
"checksum open 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c281318d992e4432cfa799969467003d05921582a7489a8325e37f8a450d5113"
@@ -4234,6 +4275,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
42344275
"checksum rls-rustc 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9dba7390427aefa953608429701e3665192ca810ba8ae09301e001b7c7bed0"
42354276
"checksum rls-span 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "33d66f1d6c6ccd5c98029f162544131698f6ebb61d8c697681cac409dcd08805"
42364277
"checksum rls-vfs 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "72d56425bd5aa86d9d4372b76f0381d3b4bda9c0220e71956c9fcc929f45c1f1"
4278+
"checksum rmp 0.8.7 (git+https://github.com/3Hren/msgpack-rust?rev=40b3d480b20961e6eeceb416b32bcd0a3383846a)" = "<none>"
4279+
"checksum rmp-serde 0.14.0 (git+https://github.com/3Hren/msgpack-rust?rev=40b3d480b20961e6eeceb416b32bcd0a3383846a)" = "<none>"
42374280
"checksum rustc-ap-arena 373.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8be999235b541fc8eb54901b66e899a06076709ac5f53d6b2c5c59d29ad54780"
42384281
"checksum rustc-ap-graphviz 373.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "532b5df15ca1a19a42815e37e521a20a7632b86b36868d1447932f8476f8f789"
42394282
"checksum rustc-ap-rustc_cratesio_shim 373.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c388afe1ef810013c878bdf9073ab1ae28dc49e9325863b351afb10acf4cc46e"
@@ -4345,3 +4388,4 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
43454388
"checksum xattr 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "244c3741f4240ef46274860397c7c74e50eb23624996930e484c16679633a54c"
43464389
"checksum xz2 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "df8bf41d3030c3577c9458fd6640a05afbf43b150d0b531b16bd77d3f794f27a"
43474390
"checksum yaml-rust 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e66366e18dc58b46801afbf2ca7661a9f59cc8c5962c29892b6039b4f86fa992"
4391+
"checksum ykpack 0.1.0 (git+https://github.com/softdevteam/ykpack)" = "<none>"

README_YORICK.md

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/librustc_codegen_llvm/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ cc = "1.0.1" # Used to locate MSVC
1515
num_cpus = "1.0"
1616
rustc-demangle = "0.1.4"
1717
rustc_llvm = { path = "../librustc_llvm" }
18-
rustc_yk_sections = { path = "../librustc_yk_sections" }
1918
memmap = "0.6"
2019

2120
[features]

src/librustc_codegen_llvm/back/link.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ use rustc::hir::def_id::CrateNum;
2424
use tempfile::{Builder as TempFileBuilder, TempDir};
2525
use rustc_target::spec::{PanicStrategy, RelroLevel, LinkerFlavor};
2626
use rustc_data_structures::fx::FxHashSet;
27-
use rustc_yk_sections::with_yk_debug_sections;
2827

2928
use std::ascii;
3029
use std::char;
@@ -545,12 +544,10 @@ fn link_natively(sess: &Session,
545544
cmd.args(args);
546545
}
547546

548-
// Link Yorick objects in.
549-
if with_yk_debug_sections() {
550-
if crate_type == config::CrateType::Executable {
551-
cmd.arg("-Wl,--no-gc-sections");
552-
cmd.args(sess.yk_link_objects.borrow().iter().map(|o| o.path()));
553-
}
547+
// Link Yorick objects into executables.
548+
if crate_type == config::CrateType::Executable {
549+
cmd.arg("-Wl,--no-gc-sections");
550+
cmd.args(sess.yk_link_objects.borrow().iter().map(|o| o.path()));
554551
}
555552

556553
for &(ref k, ref v) in &sess.target.target.options.link_env {

src/librustc_driver/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ rustc_save_analysis = { path = "../librustc_save_analysis" }
3333
rustc_traits = { path = "../librustc_traits" }
3434
rustc_codegen_utils = { path = "../librustc_codegen_utils" }
3535
rustc_typeck = { path = "../librustc_typeck" }
36-
rustc_yk_sections = { path = "../librustc_yk_sections" }
37-
rustc_yk_link = { path = "../librustc_yk_link" }
3836
rustc_interface = { path = "../librustc_interface" }
3937
serialize = { path = "../libserialize" }
4038
syntax = { path = "../libsyntax" }

src/librustc_driver/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ extern crate log;
5050
extern crate syntax;
5151
extern crate syntax_ext;
5252
extern crate syntax_pos;
53-
extern crate rustc_yk_sections;
54-
extern crate rustc_yk_link;
5553

5654
use pretty::{PpMode, UserIdentifiedItem};
5755

src/librustc_interface/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ crate-type = ["dylib"]
1010

1111
[dependencies]
1212
rustc_yk_sections = { path = "../librustc_yk_sections" }
13-
rustc_yk_link = { path = "../librustc_yk_link" }
1413
log = "0.4"
1514
rustc-rayon = "0.1.1"
1615
smallvec = { version = "0.6.7", features = ["union", "may_dangle"] }

src/librustc_interface/passes.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ use syntax::symbol::Symbol;
4646
use syntax::feature_gate::AttributeType;
4747
use syntax_pos::{FileName, hygiene};
4848
use syntax_ext;
49-
use rustc_yk_sections::mir_cfg::emit_mir_cfg_section;
50-
use rustc_yk_sections::with_yk_debug_sections;
49+
use rustc_yk_sections::mir_cfg::generate_tir;
5150
use rustc_codegen_utils::link::out_filename;
5251
use rustc::util::nodemap::DefIdSet;
5352

@@ -1040,14 +1039,18 @@ pub fn start_codegen<'tcx>(
10401039
}
10411040

10421041
// Output Yorick debug sections into binary targets.
1043-
if tcx.sess.crate_types.borrow().contains(&config::CrateType::Executable) &&
1044-
with_yk_debug_sections() {
1045-
let out_fname = out_filename(
1046-
tcx.sess, config::CrateType::Executable, &outputs,
1047-
&*tcx.crate_name(LOCAL_CRATE).as_str());
1048-
1049-
tcx.sess.yk_link_objects.borrow_mut()
1050-
.push(emit_mir_cfg_section(&tcx, &def_ids, out_fname));
1042+
if tcx.sess.crate_types.borrow().contains(&config::CrateType::Executable) {
1043+
let out_fname = out_filename(
1044+
tcx.sess, config::CrateType::Executable, &outputs,
1045+
&*tcx.crate_name(LOCAL_CRATE).as_str());
1046+
1047+
match generate_tir(&tcx, &def_ids, out_fname) {
1048+
Ok(tir) => tcx.sess.yk_link_objects.borrow_mut().push(tir),
1049+
Err(e) => {
1050+
tcx.sess.err(&format!("could not emit TIR: {}", e));
1051+
tcx.sess.abort_if_errors();
1052+
}
1053+
}
10511054
}
10521055

10531056
codegen

src/librustc_yk_sections/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ test = false
1212
[dependencies]
1313
rustc = { path = "../librustc" }
1414
rustc_yk_link = { path = "../librustc_yk_link" }
15+
ykpack = { git = "https://github.com/softdevteam/ykpack" }
1516
rustc_codegen_utils = { path = "../librustc_codegen_utils" }
16-
byteorder = "1.2"

src/librustc_yk_sections/lib.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,6 @@
1212
extern crate rustc;
1313
extern crate rustc_yk_link;
1414
extern crate rustc_codegen_utils;
15-
extern crate byteorder;
16-
17-
use std::env;
18-
19-
/// Are Yorick debug sections enabled?
20-
pub fn with_yk_debug_sections() -> bool {
21-
match env::var("YK_DEBUG_SECTIONS") {
22-
Ok(_) => true,
23-
_ => false,
24-
}
25-
}
15+
extern crate ykpack;
2616

2717
pub mod mir_cfg;

0 commit comments

Comments
 (0)