Skip to content

Commit

Permalink
LLVM crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoxc committed Dec 10, 2017
1 parent 0b49e30 commit f4b1f76
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 32 deletions.
20 changes: 0 additions & 20 deletions src/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions src/librustc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,6 @@ lazy_static = "1.0.0"
# compiles, then please feel free to do so!
flate2 = "0.2"

[target.'cfg(target_arch = "x86")'.dependencies]
x86 = { git = "https://github.com/gz/rust-x86.git" }

[target.'cfg(target_arch = "x86_64")'.dependencies]
x86 = { git = "https://github.com/gz/rust-x86.git" }

[target.'cfg(windows)'.dependencies]
kernel32-sys = "0.2.2"
winapi = "0.2.8"
2 changes: 1 addition & 1 deletion src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
html_root_url = "https://doc.rust-lang.org/nightly/")]
#![deny(warnings)]

#![feature(asm)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(conservative_impl_trait)]
Expand Down Expand Up @@ -82,7 +83,6 @@ extern crate libc;
extern crate kernel32;
#[cfg(windows)]
extern crate winapi;
extern crate x86;
extern crate owning_ref;
extern crate rustc_back;
#[macro_use] extern crate rustc_data_structures;
Expand Down
19 changes: 16 additions & 3 deletions src/librustc/util/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,22 @@ fn time_threads_impl<T, F>(what: &str, f: F) -> T where
{
use rayon_core::registry;
use std::iter;
use x86;
use winapi;
use kernel32;

#[allow(unused_mut)]
fn read_counter() -> u64 {
let mut low: u32;
let mut high: u32;

unsafe {
asm!("xor %%rax, %%rax; cpuid; rdtsc"
: "={eax}" (low), "={edx}" (high) :: "memory,rbx,rcx");
}

((high as u64) << 32) | (low as u64)
}

let registry = registry::get_current_registry();
if let Some(registry) = registry {
let freq = unsafe {
Expand All @@ -186,9 +198,10 @@ fn time_threads_impl<T, F>(what: &str, f: F) -> T where
assert!(kernel32::QueryThreadCycleTime(handle, &mut begin[i]) == winapi::TRUE);
}
}
let time_start = unsafe { x86::shared::time::rdtsc() };

let time_start = read_counter();
let result = f();
let time_end = unsafe { x86::shared::time::rdtsc() };
let time_end = read_counter();
for (i, &handle) in threads.iter().enumerate() {
unsafe {
assert!(kernel32::QueryThreadCycleTime(handle, &mut end[i]) == winapi::TRUE);
Expand Down
8 changes: 6 additions & 2 deletions src/librustc_driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -787,9 +787,13 @@ pub fn phase_2_configure_and_expand<F>(sess: &Session,
let mut ecx = ExtCtxt::new(&sess.parse_sess, cfg, &mut resolver);
let err_count = ecx.parse_sess.span_diagnostic.err_count();

let krate = ecx.monotonic_expander().expand_crate(krate);
let krate = time(time_passes, "expand crate", || {
ecx.monotonic_expander().expand_crate(krate);
});

ecx.check_unused_macros();
time(time_passes, "check unused macros", || {
ecx.check_unused_macros();
});

let mut missing_fragment_specifiers: Vec<_> =
ecx.parse_sess.missing_fragment_specifiers.borrow().iter().cloned().collect();
Expand Down

0 comments on commit f4b1f76

Please sign in to comment.