Skip to content

Commit 3da4023

Browse files
committed
Auto merge of rust-lang#40779 - arielb1:bad-arm, r=alexcrichton
update LLVM with fix for PR32379 Fixes rust-lang#40593. The "root" codegen bug fixed here is that, when generating ARM code, unpatched LLVM 3.9/3.9.1 miscompiles bit operations in rare circumstances - this can cause user code compiled via LLVM (through both `rustc` and `clang`) to subtly return incorrect results - for more details, see the test in this PR or in the LLVM rare report. One effect of that LLVM bug is that `rustc` 1.17 (and possibly other versions) is miscompiled on ARM. The code generated by a miscompiled `rustc` lacks destructor calls in many circumstances. Users who run an affected/miscompiled `rustc` - 1.17 or above - on an ARM build machine will be affected by the (fairly blatant) missing destructor bug, regardless of the target architecture (this includes the official `1.17.0-beta.1`, `1.17.0-beta.2`, and some official 1.17/1.18 nightlies). Users who use an affected LLVM (that's any unpatched LLVM 3.9/3.9.1), whether through `rustc` (in any version that supports 3.9 - that's 1.12 or above) or through `clang`, who compile code to an ARM target architecture might be affected by the (fairly hard to hit) bit operation bug, regardless of the build machine. Distributors and user who want to compile rustc using their own LLVM should apply the [patch](llvm-mirror/llvm@cdc303e) to avoid miscompilations. r? @alexcrichton Beta-nominating because regression (rustc 1.16 is not blatantly miscompiled). This also picks a fix for the (MSVC-affecting) PR29151.
2 parents 8cf8fc9 + bd52ff1 commit 3da4023

File tree

4 files changed

+40
-2
lines changed

4 files changed

+40
-2
lines changed

src/rustllvm/llvm-rebuild-trigger

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# If this file is modified, then llvm will be (optionally) cleaned and then rebuilt.
22
# The actual contents of this file do not matter, but to trigger a change on the
33
# build bots then the contents should be changed so git updates the mtime.
4-
2017-03-19
4+
2017-03-23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
pub fn pr32379(mut data: u64, f1: bool, f2: bool) -> u64 {
12+
if f1 { data &= !2; }
13+
if f2 { data |= 2; }
14+
data
15+
}

src/test/run-pass/llvm-pr32379.rs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// aux-build:llvm_pr32379.rs
12+
13+
// LLVM PR #32379 (https://bugs.llvm.org/show_bug.cgi?id=32379), which
14+
// applies to upstream LLVM 3.9.1, is known to cause rustc itself to be
15+
// miscompiled on ARM (Rust issue #40593). Because cross builds don't test
16+
// our *compiler* on ARM, have a test for the miscompilation directly.
17+
18+
extern crate llvm_pr32379;
19+
20+
pub fn main() {
21+
let val = llvm_pr32379::pr32379(2, false, false);
22+
assert_eq!(val, 2);
23+
}

0 commit comments

Comments
 (0)