Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit b5cf44d

Browse files
committed
handle rustc_span unsafe blocks
Signed-off-by: onur-ozkan <work@onurozkan.dev>
1 parent b6abb33 commit b5cf44d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

compiler/rustc_span/src/analyze_source_file.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,30 @@ cfg_match! {
8383

8484
// For character in the chunk, see if its byte value is < 0, which
8585
// indicates that it's part of a UTF-8 char.
86+
#[cfg(bootstrap)]
87+
let multibyte_test = unsafe { _mm_cmplt_epi8(chunk, _mm_set1_epi8(0)) };
88+
#[cfg(not(bootstrap))]
8689
let multibyte_test = _mm_cmplt_epi8(chunk, _mm_set1_epi8(0));
90+
8791
// Create a bit mask from the comparison results.
92+
#[cfg(bootstrap)]
93+
let multibyte_mask = unsafe { _mm_movemask_epi8(multibyte_test) };
94+
#[cfg(not(bootstrap))]
8895
let multibyte_mask = _mm_movemask_epi8(multibyte_test);
8996

9097
// If the bit mask is all zero, we only have ASCII chars here:
9198
if multibyte_mask == 0 {
9299
assert!(intra_chunk_offset == 0);
93100

94101
// Check for newlines in the chunk
102+
#[cfg(bootstrap)]
103+
let newlines_test = unsafe { _mm_cmpeq_epi8(chunk, _mm_set1_epi8(b'\n' as i8)) };
104+
#[cfg(not(bootstrap))]
95105
let newlines_test = _mm_cmpeq_epi8(chunk, _mm_set1_epi8(b'\n' as i8));
106+
107+
#[cfg(bootstrap)]
108+
let mut newlines_mask = unsafe { _mm_movemask_epi8(newlines_test) };
109+
#[cfg(not(bootstrap))]
96110
let mut newlines_mask = _mm_movemask_epi8(newlines_test);
97111

98112
let output_offset = RelativeBytePos::from_usize(chunk_index * CHUNK_SIZE + 1);

0 commit comments

Comments
 (0)