Reachable statics have reachable initializers
Static initializer can read other statics. Initializers are evaluated at compile time, and so their content could become inlined into another crate. Ensure that initializers of reachable statics are also reachable. Previously, when an item incorrectly considered to be unreachable was reached from another crate an attempt would be made to codegen it. The attempt could fail with an ICE (in the case MIR wasn't available to do so) in some circumstances the attempt could also succeed resulting in a local codegen of non-local items, including static ones.
This commit is contained in:
parent
13a2615883
commit
eaddc8febd
4 changed files with 26 additions and 6 deletions
|
|
@ -58,7 +58,6 @@ const HIDDEN: () = {
|
|||
pub static mut L: u8 = 0;
|
||||
};
|
||||
|
||||
// The surrounding item should not accidentally become external
|
||||
fn x() {
|
||||
// CHECK: @M = local_unnamed_addr constant
|
||||
#[no_mangle]
|
||||
|
|
@ -76,6 +75,3 @@ fn x() {
|
|||
#[no_mangle]
|
||||
pub static mut P: u8 = 0;
|
||||
}
|
||||
// CHECK-LABEL: ; external_no_mangle_statics::x
|
||||
// CHECK-NEXT: ; Function Attrs:
|
||||
// CHECK-NEXT: define internal
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue