Uh oh!
There was an error while loading. Please reload this page.
Add forever unstable attribute to allow specifying arbitrary scalar ranges - #54032
Conversation
There was a problem hiding this comment.
Can we do something less magic-value like than this? 0xFFFF_FFFB is two steps away from the values in SCOPE_DATA_*. Changing the definition of SCOPE_DATA_* to be 0xFFFF_FFFE, ... 0xFFFF_FFFD would help somewhat, if it is not possible to use arithmetic in the attribute.
There was a problem hiding this comment.
SCOPE_DATA_DESTRUCTION is 0xFFFF_FFFC, so this is exactly next to it.
Attributes currently only allow literals, no expressions. Though referring to constants might work via queries, there's currently no support for that.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Why isn't this done by having an enum with 4 unit variants and a tuple variant around FirstStatementIndex?
There was a problem hiding this comment.
You can use the RangeBound enum from libstd instead of Option here.
eddyb
commented
Sep 8, 2018
@oli-obk I think the name should have |
7e185fc to
95987d0Compare2285e76 to
8053f63Compare| #[allow(dead_code)] | ||
| // only works on stage 1 when the rustc_layout_scalar_valid_range attribute actually exists | ||
| #[cfg(not(stage0))] | ||
| static ASSERT: () = [()][(mem::size_of::<ScopeData>() != 4) as usize]; |
There was a problem hiding this comment.
I would put ! around the expression and use == instead of !=. That way, it reads more like an assert.
Uh oh!
There was an error while loading. Please reload this page.
| @type [$name] | ||
| @max [::std::u32::MAX - 1] | ||
| // shave off 256 indices at the end to allow space for packing these indices into enums | ||
| @max [0xFFFF_FF00] |
| @@ -0,0 +1,5 @@ | |||
| // compile-pass | |||
| static ASSERT: () = [()][(std::mem::size_of::<u32>() != 4) as usize]; | |||
There was a problem hiding this comment.
I'd make the same change here (! around ==).
Uh oh!
There was an error while loading. Please reload this page.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
oli-obk
commented
Sep 11, 2018
Ups forgot to push. Stage 2 tests are passing locally now. |
I'm presuming @bors r=eddyb since all review comments have been addressed |
bors
commented
Sep 11, 2018
📌 Commit 79f2cc0 has been approved by |
This comment has been minimized.
This comment has been minimized.
| ScopeData::Destruction => write!(fmt, "Destruction({:?})", self.id), | ||
| ScopeData::Remainder(fsi) => write!( | ||
| fmt, | ||
| "Remainder {{ block: {:?}, first_statement_index: {}}}", |
There was a problem hiding this comment.
You probably want to use the fmt.debug_struct wrapper, to automate this.
eddyb
commented
Sep 11, 2018
@bors r+ |
bors
commented
Sep 11, 2018
📌 Commit a94c166 has been approved by |
nikomatsakis
left a comment
There was a problem hiding this comment.
OK, I was wrong. This is awesome! Nice work @oli-obk! 🎉
bors
commented
Sep 14, 2018
Add forever unstable attribute to allow specifying arbitrary scalar ranges r? @eddyb for the first commit and @nikomatsakis for the second one
bors
commented
Sep 14, 2018
☀️ Test successful - status-appveyor, status-travis |
Make rustc::middle::region::Scope's fields public This PR makes the following changes to `rustc::middle::region::Scope`: - [x] Makes `region::Scope`'s fields public - [x] Removes the `impl Scope` block with constructors (as per [this comment](#54032 (comment))) - [x] Updates call sites throughout the compiler Closes#54122.
nnethercote
commented
Sep 22, 2018
This hurt compile speed by up to 2% across a lot of benchmarks: @oli-obk: any thoughts? |
oli-obk
commented
Sep 22, 2018
Previously the unpacking was done manually. Now ruatc generates the relevant enum matching code. Maybe it's not as optimizeable? |
nnethercote
commented
Sep 25, 2018
@oli-obk: Here is a Cachegrind diff comparing instruction counts before vs. after. Positive numbers means the instruction counts went up, negative numbers mean they went down. Any more thoughts about how to fix the regression? |
oli-obk
commented
Oct 1, 2018
I'll create some artificial benchmarks to try to repro the issue in isolation. Without knowing which case exactly is slow/verbose and we'd be poking in the dark. |
oli-obk
commented
Oct 13, 2018
I think I know the reason for this now. I changed e.g. constFOO_A:u32 = 0xFFFF_FFFF;constFOO_B:u32 = 0xFFFF_FFFE;structFoo{u:u32}to #[rustc_layout_scalar_range_end(0xFFFF_FF00)]structBar(u32);enumFoo{A,B,Other(Bar),}While this will result in pretty much the same layout as before, any derived code on The llvm IR for the second playground link is ca 150 LOC, the first link has 50 LOC I'm opening an issue for this problem, since I can also create an example on stable code (without the unstable attribute) that will result in the same lack of optimitations |
r? @eddyb for the first commit and @nikomatsakis for the second one