Skip to content

Commit

Permalink
Reject non-naturally aligned loads and stores.
Browse files Browse the repository at this point in the history
  • Loading branch information
vext01 committed Nov 11, 2024
1 parent 44fcf1a commit cf01cbf
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions llvm/lib/YkIR/YkIRWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -886,23 +886,21 @@ class YkIRWriter {
// - loads from exotic address spaces
// - potentially misaligned loads
//
// FIXME: About misaligned loads, when a load is aligned `N`, this is a hard
// guarantee to the code generator that at runtime, the pointer is aligned
// to N bytes. The codegen uses this to decide whether or not to split the
// operation into multiple loads (in order to avoid a memory access
// straddling an alignment boundary on a CPU that disallows such things).
//
// For now we let through only loads with an alignment greater-than or
// equal-to the size of the type of the data being loaded. Such cases are
// trivially safe, since the codegen will never have to face an unaligned
// load for these.
// FIXME: About the `align` keyword for load instructions: `align N` is a
// hard guarantee to the code generator that at runtime, the pointer is
// aligned to N bytes. The codegen uses this to decide whether or not to
// split the operation into multiple loads (in order to avoid a memory
// access straddling an alignment boundary on a CPU that disallows such
// things). Since many parts of the JIT assume that an object's memory is
// naturally aligned, for now we let through only loads with natural
// alignment.
//
// Eventually we will have to encode the alignment of the load into our IR
// and have the trace code generator split up the loads where necessary.
// The same will have to be done for store instructions.
if ((I->getOrdering() != AtomicOrdering::NotAtomic) ||
(I->getPointerAddressSpace() != 0) ||
(I->getAlign() < DL.getTypeAllocSize(I->getType()))) {
(I->getAlign() != DL.getTypeAllocSize(I->getType()))) {
serialiseUnimplementedInstruction(I, FLCtxt, BBIdx, InstIdx);
return;
}
Expand All @@ -925,13 +923,12 @@ class YkIRWriter {
// We don't yet support:
// - atomic store
// - stores into exotic address spaces
// - potentially misaligned stores
// - non-natural alignments
//
// See the comment in `serialiseLoadInst()` for context on misaligned memory
// accesses.
// See the comment in `serialiseLoadInst()` for context on alignment.
if ((I->getOrdering() != AtomicOrdering::NotAtomic) ||
(I->getPointerAddressSpace() != 0) ||
(I->getAlign() <
(I->getAlign() !=
DL.getTypeAllocSize(I->getValueOperand()->getType()))) {
serialiseUnimplementedInstruction(I, FLCtxt, BBIdx, InstIdx);
return;
Expand Down

0 comments on commit cf01cbf

Please sign in to comment.