diff options
| author | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2020-05-02 21:44:25 +0200 |
|---|---|---|
| committer | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2020-05-30 12:59:05 +0200 |
| commit | 0aa7f4d2f2ff55b8cfe5de5e4e7665a8fdeaf050 (patch) | |
| tree | 1aa0aed21020a916efac714459a6ba07c6f82f06 /src/test | |
| parent | 0e9e4083100aa3ebf09b8f1ace0348cb37475eb9 (diff) | |
Make TLS accesses explicit in MIR
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/mir-opt/tls-access.rs | 13 | ||||
| -rw-r--r-- | src/test/mir-opt/tls-access/rustc.main.SimplifyCfg-final.after.mir | 40 |
2 files changed, 53 insertions, 0 deletions
diff --git a/src/test/mir-opt/tls-access.rs b/src/test/mir-opt/tls-access.rs new file mode 100644 index 00000000000..4f3f6b1b3ac --- /dev/null +++ b/src/test/mir-opt/tls-access.rs @@ -0,0 +1,13 @@ +#![feature(thread_local)] + +#[thread_local] +static mut FOO: u8 = 3; + +fn main() { + unsafe { + let a = &FOO; + FOO = 42; + } +} + +// EMIT_MIR rustc.main.SimplifyCfg-final.after.mir diff --git a/src/test/mir-opt/tls-access/rustc.main.SimplifyCfg-final.after.mir b/src/test/mir-opt/tls-access/rustc.main.SimplifyCfg-final.after.mir new file mode 100644 index 00000000000..e4798c2e324 --- /dev/null +++ b/src/test/mir-opt/tls-access/rustc.main.SimplifyCfg-final.after.mir @@ -0,0 +1,40 @@ +// MIR for `main` after SimplifyCfg-final + +fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/tls-access.rs:6:11: 6:11 + let _2: *mut u8; // in scope 0 at $DIR/tls-access.rs:8:18: 8:21 + let mut _3: *mut u8; // in scope 0 at $DIR/tls-access.rs:9:9: 9:12 + scope 1 { + let _1: &u8; // in scope 1 at $DIR/tls-access.rs:8:13: 8:14 + scope 2 { + debug a => _1; // in scope 2 at $DIR/tls-access.rs:8:13: 8:14 + } + } + + bb0: { + StorageLive(_1); // scope 1 at $DIR/tls-access.rs:8:13: 8:14 + StorageLive(_2); // scope 1 at $DIR/tls-access.rs:8:18: 8:21 + _2 = &/*tls*/ mut FOO; // scope 1 at $DIR/tls-access.rs:8:18: 8:21 + _1 = &(*_2); // scope 1 at $DIR/tls-access.rs:8:17: 8:21 + StorageLive(_3); // scope 2 at $DIR/tls-access.rs:9:9: 9:12 + _3 = &/*tls*/ mut FOO; // scope 2 at $DIR/tls-access.rs:9:9: 9:12 + (*_3) = const 42u8; // scope 2 at $DIR/tls-access.rs:9:9: 9:17 + // ty::Const + // + ty: u8 + // + val: Value(Scalar(0x2a)) + // mir::Constant + // + span: $DIR/tls-access.rs:9:15: 9:17 + // + literal: Const { ty: u8, val: Value(Scalar(0x2a)) } + StorageDead(_3); // scope 2 at $DIR/tls-access.rs:9:17: 9:18 + _0 = const (); // scope 1 at $DIR/tls-access.rs:7:5: 10:6 + // ty::Const + // + ty: () + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/tls-access.rs:7:5: 10:6 + // + literal: Const { ty: (), val: Value(Scalar(<ZST>)) } + StorageDead(_2); // scope 1 at $DIR/tls-access.rs:10:5: 10:6 + StorageDead(_1); // scope 1 at $DIR/tls-access.rs:10:5: 10:6 + return; // scope 0 at $DIR/tls-access.rs:11:2: 11:2 + } +} |
