diff options
| author | bors <bors@rust-lang.org> | 2020-04-03 20:56:05 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-04-03 20:56:05 +0000 |
| commit | 74bd074eefcf4915c73d1ab91bc90859664729e6 (patch) | |
| tree | 4eb869837e228d81b08b2fb4db3ad1af00942039 /src/librustc_codegen_llvm | |
| parent | f6fe99c798cb65280a9a56f442b371adcb7b8aa2 (diff) | |
| parent | 4c41ea36cda77748b532cf6d989a8d5d2fcc872e (diff) | |
Auto merge of #70747 - Centril:rollup-2vx9bve, r=Centril
Rollup of 9 pull requests Successful merges: - #69860 (Use associated numeric consts in documentation) - #70576 (Update the description of the ticket to point at RFC 1721) - #70597 (Fix double-free and undefined behaviour in libstd::syn::unix::Thread::new) - #70640 (Hide `task_context` when lowering body) - #70641 (Remove duplicated code in trait selection) - #70707 (Remove unused graphviz emitter) - #70720 (Place TLS initializers with relocations in .tdata) - #70735 (Clean up E0502 explanation) - #70741 (Add test for #59023) Failed merges: r? @ghost
Diffstat (limited to 'src/librustc_codegen_llvm')
| -rw-r--r-- | src/librustc_codegen_llvm/consts.rs | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/src/librustc_codegen_llvm/consts.rs b/src/librustc_codegen_llvm/consts.rs index 2d5564abfb2..9fd22c8b07b 100644 --- a/src/librustc_codegen_llvm/consts.rs +++ b/src/librustc_codegen_llvm/consts.rs @@ -436,24 +436,21 @@ impl StaticMethods for CodegenCx<'ll, 'tcx> { // // We could remove this hack whenever we decide to drop macOS 10.10 support. if self.tcx.sess.target.target.options.is_like_osx { - assert_eq!(alloc.relocations().len(), 0); - - let is_zeroed = { - // Treats undefined bytes as if they were defined with the byte value that - // happens to be currently assigned in mir. This is valid since reading - // undef bytes may yield arbitrary values. - // - // FIXME: ignore undef bytes even with representation `!= 0`. - // - // The `inspect` method is okay here because we checked relocations, and - // because we are doing this access to inspect the final interpreter state - // (not as part of the interpreter execution). - alloc + // The `inspect` method is okay here because we checked relocations, and + // because we are doing this access to inspect the final interpreter state + // (not as part of the interpreter execution). + // + // FIXME: This check requires that the (arbitrary) value of undefined bytes + // happens to be zero. Instead, we should only check the value of defined bytes + // and set all undefined bytes to zero if this allocation is headed for the + // BSS. + let all_bytes_are_zero = alloc.relocations().is_empty() + && alloc .inspect_with_undef_and_ptr_outside_interpreter(0..alloc.len()) .iter() - .all(|b| *b == 0) - }; - let sect_name = if is_zeroed { + .all(|&byte| byte == 0); + + let sect_name = if all_bytes_are_zero { CStr::from_bytes_with_nul_unchecked(b"__DATA,__thread_bss\0") } else { CStr::from_bytes_with_nul_unchecked(b"__DATA,__thread_data\0") |
