Skip to content

[SYCL] Implement and use aligned allocator - #88

Merged
romanovvlad merged 1 commit into
intel:syclfrom
MrSidims:private/MrSidims/align_alloc
Apr 19, 2019
Merged

romanovvlad merged 1 commit into
intel:syclfrom
MrSidims:private/MrSidims/align_alloc

Conversation

@MrSidims

Copy link
Copy Markdown
Contributor

Alignment is of 64 bytes by default.
Buffer is not longer zero-initialized.

Signed-off-by: Dmitry Sidorov [email protected]

@keryell keryell left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems like an interesting feature to have.
I have just a few questions & comments.

Comment thread sycl/include/CL/sycl/detail/aligned_allocator.hpp Outdated
Comment thread sycl/include/CL/sycl/detail/aligned_allocator.hpp Outdated
Comment thread sycl/include/CL/sycl/detail/aligned_allocator.hpp Outdated
Comment thread sycl/include/CL/sycl/detail/aligned_allocator.hpp Outdated
Comment thread sycl/include/CL/sycl/detail/aligned_allocator.hpp Outdated
Comment thread sycl/include/CL/sycl/detail/buffer_impl.hpp Outdated
Comment thread sycl/include/CL/sycl/detail/buffer_impl.hpp Outdated
Comment thread sycl/include/CL/sycl/detail/buffer_impl.hpp Outdated
Comment thread sycl/include/CL/sycl/detail/buffer_impl.hpp Outdated
Comment thread sycl/test/sub_group/vote.cpp Outdated

@keryell keryell left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps an assignment operator to remove?

Comment thread sycl/include/CL/sycl/detail/aligned_allocator.hpp Outdated
Alignment is of 64 bytes by default.
Buffer is not longer zero-initialized.

Signed-off-by: Dmitry Sidorov <[email protected]>
@MrSidims

Copy link
Copy Markdown
Contributor Author

Perhaps an assignment operator to remove?

You are right, thanks!

@romanovvlad
romanovvlad merged commit f207062 into intel:sycl Apr 19, 2019
coldav pushed a commit to coldav/llvm that referenced this pull request Aug 29, 2025
…t-wis

[compiler] Remove MaterializeAbsentWorkItemBuiltinsPass
iclsrc pushed a commit that referenced this pull request Aug 4, 2026
Swift async functions can miscompile on Windows ARM64 at `-O2`, when
there's enough register pressure that a local gets scavenged into the
callee-save area: the local ends up sharing an address with the saved
caller x29, so the epilogue restores a value the function has already
overwritten. swiftlang/swift#90920 has a reduced repro.

`assignCalleeSavedSpillSlots` creates the swift async context object
before the callee-save loop instead of inside it next to the FP slot.
MachineFrameInfo ends up with it above the frame record while the
prologue stores it below at FP-8, and the 8 byte disagreement leaves a
hole in the middle of the callee-save area. PEI's scavenger hands that
hole to the local. Only reproduces at -O2 and up since scavenging is
gated on the opt level.

```
	sub	sp, sp, #112
	str	x19, [sp, #16]                  // 8-byte Spill
	str	x21, [sp, #24]                  // 8-byte Spill
	stp	x23, x24, [sp, #32]             // 16-byte Folded Spill
	stp	x25, x26, [sp, #48]             // 16-byte Folded Spill
	stp	x27, x28, [sp, #64]             // 16-byte Folded Spill
	stp	x29, x30, [sp, #88]             // 16-byte Folded Spill
	str	xzr, [sp, #80]
	add	x29, sp, #88
	...
	str	x7, [x29]                       // 8-byte Spill
	...
	ldr	x1, [x29]                       // 8-byte Reload
	ldp	x29, x30, [sp, #88]             // 16-byte Folded Reload
```

This creates the object inside the loop so the two agree. The other
option was leaving the creation site alone and teaching MachineFrameInfo
about the expanded 24 byte FP/LR slot, but that puts the layout in two
places. Not sure which is preferred here, I don't know this code well.

This also asserts the saved FP object resolves to FP+0, since nothing
checks that today. Reverting the fix makes it fire on the same funclet.
`store-swift-async-context-clobber-live-reg.ll` already miscompiles with
`-regalloc=fast`, so this isn't Swift specific.
dyniols pushed a commit that referenced this pull request Oct 2, 2026
Swift async functions can miscompile on Windows ARM64 at `-O2`, when
there's enough register pressure that a local gets scavenged into the
callee-save area: the local ends up sharing an address with the saved
caller x29, so the epilogue restores a value the function has already
overwritten. swiftlang/swift#90920 has a reduced repro.

`assignCalleeSavedSpillSlots` creates the swift async context object
before the callee-save loop instead of inside it next to the FP slot.
MachineFrameInfo ends up with it above the frame record while the
prologue stores it below at FP-8, and the 8 byte disagreement leaves a
hole in the middle of the callee-save area. PEI's scavenger hands that
hole to the local. Only reproduces at -O2 and up since scavenging is
gated on the opt level.

```
	sub	sp, sp, #112
	str	x19, [sp, #16]                  // 8-byte Spill
	str	x21, [sp, #24]                  // 8-byte Spill
	stp	x23, x24, [sp, #32]             // 16-byte Folded Spill
	stp	x25, x26, [sp, #48]             // 16-byte Folded Spill
	stp	x27, x28, [sp, #64]             // 16-byte Folded Spill
	stp	x29, x30, [sp, #88]             // 16-byte Folded Spill
	str	xzr, [sp, #80]
	add	x29, sp, #88
	...
	str	x7, [x29]                       // 8-byte Spill
	...
	ldr	x1, [x29]                       // 8-byte Reload
	ldp	x29, x30, [sp, #88]             // 16-byte Folded Reload
```

This creates the object inside the loop so the two agree. The other
option was leaving the creation site alone and teaching MachineFrameInfo
about the expanded 24 byte FP/LR slot, but that puts the layout in two
places. Not sure which is preferred here, I don't know this code well.

This also asserts the saved FP object resolves to FP+0, since nothing
checks that today. Reverting the fix makes it fire on the same funclet.
`store-swift-async-context-clobber-live-reg.ll` already miscompiles with
`-regalloc=fast`, so this isn't Swift specific.

(cherry picked from commit c358e8d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants