-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce verification of integer address type widths. #10209
Changes from all commits
76679be
3c1c066
85d1399
76e6222
4291fad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,21 +73,3 @@ block0(v0: f64): | |
; run: %fdemote_is_nan(-sNaN:0x1) == 1 | ||
; run: %fdemote_is_nan(+sNaN:0x4000000000001) == 1 | ||
; run: %fdemote_is_nan(-sNaN:0x4000000000001) == 1 | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Most of the changes from the unit tests are very mechanical. I kept as many test cases in the existing file, and split out 32 and 64 bit-specific unit tests to Most often the change is the number in the |
||
|
||
;; Tests a fdemote+load combo which some backends may optimize | ||
function %fdemote_load(i64, f64) -> f32 { | ||
ss0 = explicit_slot 16 | ||
|
||
block0(v1: i64, v2: f64): | ||
v3 = stack_addr.i64 ss0 | ||
store.f64 v2, v3 | ||
v4 = load.f64 v3 | ||
v5 = fdemote.f32 v4 | ||
return v5 | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
; run: %fdemote_load(0, 0x0.0) == 0x0.0 | ||
; run: %fdemote_load(1, 0x0.1) == 0x0.1 | ||
; run: %fdemote_load(2, 0x0.2) == 0x0.2 | ||
; run: %fdemote_load(3, 0x3.2) == 0x3.2 | ||
; run: %fdemote_load(0x8, 0x3.2) == 0x3.2 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
test interpret | ||
test run | ||
target pulley32 | ||
target pulley32be | ||
|
||
;; Tests a fdemote+load combo which some backends may optimize | ||
function %fdemote_load(i32, f64) -> f32 { | ||
ss0 = explicit_slot 16 | ||
|
||
block0(v1: i32, v2: f64): | ||
v3 = stack_addr.i32 ss0 | ||
store.f64 v2, v3 | ||
v4 = load.f64 v3 | ||
v5 = fdemote.f32 v4 | ||
return v5 | ||
} | ||
; run: %fdemote_load(0, 0x0.0) == 0x0.0 | ||
; run: %fdemote_load(1, 0x0.1) == 0x0.1 | ||
; run: %fdemote_load(2, 0x0.2) == 0x0.2 | ||
; run: %fdemote_load(3, 0x3.2) == 0x3.2 | ||
; run: %fdemote_load(0x8, 0x3.2) == 0x3.2 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
test interpret | ||
test run | ||
target x86_64 | ||
target x86_64 has_avx | ||
target s390x | ||
target aarch64 | ||
target riscv64 | ||
target pulley64 | ||
target pulley64be | ||
|
||
;; Tests a fdemote+load combo which some backends may optimize | ||
function %fdemote_load(i64, f64) -> f32 { | ||
ss0 = explicit_slot 16 | ||
|
||
block0(v1: i64, v2: f64): | ||
v3 = stack_addr.i64 ss0 | ||
store.f64 v2, v3 | ||
v4 = load.f64 v3 | ||
v5 = fdemote.f32 v4 | ||
return v5 | ||
} | ||
; run: %fdemote_load(0, 0x0.0) == 0x0.0 | ||
; run: %fdemote_load(1, 0x0.1) == 0x0.1 | ||
; run: %fdemote_load(2, 0x0.2) == 0x0.2 | ||
; run: %fdemote_load(3, 0x3.2) == 0x3.2 | ||
; run: %fdemote_load(0x8, 0x3.2) == 0x3.2 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
test interpret | ||
test run | ||
target pulley32 | ||
target pulley32be | ||
|
||
;; Tests a fpromote+load combo which some backends may optimize | ||
function %fpromote_load(i64, f32) -> f64 { | ||
ss0 = explicit_slot 16 | ||
|
||
block0(v1: i64, v2: f32): | ||
v3 = stack_addr.i32 ss0 | ||
store.f32 v2, v3 | ||
v4 = load.f32 v3 | ||
v5 = fpromote.f64 v4 | ||
return v5 | ||
} | ||
; run: %fpromote_load(0, 0x0.0) == 0x0.0 | ||
; run: %fpromote_load(1, 0x0.1) == 0x0.1 | ||
; run: %fpromote_load(2, 0x0.2) == 0x0.2 | ||
; run: %fpromote_load(3, 0x3.2) == 0x3.2 | ||
; run: %fpromote_load(0xC, 0x3.2) == 0x3.2 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
test interpret | ||
test run | ||
target x86_64 | ||
target x86_64 has_avx | ||
target s390x | ||
target aarch64 | ||
target riscv64 | ||
target riscv64 has_c has_zcb | ||
target pulley64 | ||
target pulley64be | ||
|
||
;; Tests a fpromote+load combo which some backends may optimize | ||
function %fpromote_load(i64, f32) -> f64 { | ||
ss0 = explicit_slot 16 | ||
|
||
block0(v1: i64, v2: f32): | ||
v3 = stack_addr.i64 ss0 | ||
store.f32 v2, v3 | ||
v4 = load.f32 v3 | ||
v5 = fpromote.f64 v4 | ||
return v5 | ||
} | ||
; run: %fpromote_load(0, 0x0.0) == 0x0.0 | ||
; run: %fpromote_load(1, 0x0.1) == 0x0.1 | ||
; run: %fpromote_load(2, 0x0.2) == 0x0.2 | ||
; run: %fpromote_load(3, 0x3.2) == 0x3.2 | ||
; run: %fpromote_load(0xC, 0x3.2) == 0x3.2 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
test interpret | ||
test run | ||
target pulley32 | ||
target pulley32be | ||
|
||
function %extractlane_i8x16_through_stack(i8x16) -> i8 { | ||
ss0 = explicit_slot 8 | ||
block0(v0: i8x16): | ||
v2 = stack_addr.i32 ss0 | ||
v3 = extractlane v0, 1 | ||
store v3, v2 | ||
v4 = load.i8 v2 | ||
return v4 | ||
} | ||
; run: %extractlane_i8x16_through_stack([1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16]) == 2 | ||
|
||
function %extractlane_i16x8_through_stack(i16x8) -> i16 { | ||
ss0 = explicit_slot 8 | ||
block0(v0: i16x8): | ||
v2 = stack_addr.i32 ss0 | ||
v3 = extractlane v0, 2 | ||
store v3, v2 | ||
v4 = load.i16 v2 | ||
return v4 | ||
} | ||
; run: %extractlane_i16x8_through_stack([1 2 3 4 5 6 7 8]) == 3 | ||
|
||
function %extractlane_i32x4_through_stack(i32x4) -> i32 { | ||
ss0 = explicit_slot 8 | ||
block0(v0: i32x4): | ||
v2 = stack_addr.i32 ss0 | ||
v3 = extractlane v0, 3 | ||
store v3, v2 | ||
v4 = load.i32 v2 | ||
return v4 | ||
} | ||
; run: %extractlane_i32x4_through_stack([1 2 3 4]) == 4 | ||
|
||
function %extractlane_i64x2_through_stack(i64x2) -> i64 { | ||
ss0 = explicit_slot 8 | ||
block0(v0: i64x2): | ||
v2 = stack_addr.i32 ss0 | ||
v3 = extractlane v0, 0 | ||
store v3, v2 | ||
v4 = load.i64 v2 | ||
return v4 | ||
} | ||
; run: %extractlane_i64x2_through_stack([1 2]) == 1 | ||
|
||
function %extractlane_f32x4_through_stack(f32x4) -> f32 { | ||
ss0 = explicit_slot 8 | ||
block0(v0: f32x4): | ||
v2 = stack_addr.i32 ss0 | ||
v3 = extractlane v0, 3 | ||
store v3, v2 | ||
v4 = load.f32 v2 | ||
return v4 | ||
} | ||
; run: %extractlane_f32x4_through_stack([0x1.0 0x2.0 0x3.0 0x4.0]) == 0x4.0 | ||
|
||
function %extractlane_f64x2_through_stack(f64x2) -> f64 { | ||
ss0 = explicit_slot 8 | ||
block0(v0: f64x2): | ||
v2 = stack_addr.i32 ss0 | ||
v3 = extractlane v0, 0 | ||
store v3, v2 | ||
v4 = load.f64 v2 | ||
return v4 | ||
} | ||
; run: %extractlane_f64x2_through_stack([0x1.0 0x2.0]) == 0x1.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I initially assumed
p
was the first value of (undocumented) Store was the pointer, just like the other operations. Only after I checked store did I realise it uses the second argument as the pointer. I wonder if the capitalised flavours should be hidden from the documentation?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's somewhat surprising, but I think this is probably outside the scope of this PR -- ideally we'd unify the arg order, not try to selectively hide documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, so my confusion was that
store
andStore
exist, but only store has useful docs and parameter names. ClickingSource
forstore
shows:Which calls into the uppercase Store, I needed to look at this generated code to confirm that the second argument (
arg1
) ofStore
is the address, it's not the end of the world, because the unit tests just failed the other way around, and most people that need to know the order are likely spelunking in the code anyway?I see now that the lowercase
store
does determine thectrl_typevar
, sostore
andStore
do different things, I glossed over that initially, maybeStore
should just get more extensive documentation at some point, or link tostore
for it. Anyways, definitely beyond the scope of this PR, but hopefully this clarifies my train of thought as an outsider :)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the distinction is that
Store
names an instruction format, andstore
-the-opcode is one of the instructions that usesStore
-the-format. Perhaps we could clean this up later, thanks.