Skip to content

Commit c7d7cf1

Browse files
authored
Merge pull request rust-lang#171 from vext01/relax-align
Allow loads and stores with align >= the size of the data.
2 parents 90737ba + ee489ee commit c7d7cf1

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

llvm/lib/YkIR/YkIRWriter.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -718,14 +718,17 @@ class YkIRWriter {
718718
// operation into multiple loads (in order to avoid a memory access
719719
// straddling an alignment boundary on a CPU that disallows such things).
720720
//
721-
// For now we are going to reject any load that has an alignment value not
722-
// the same as the natural alignment of the type of the data being loaded.
721+
// For now we let through only loads with an alignment greater-than or
722+
// equal-to the size of the type of the data being loaded. Such cases are
723+
// trivially safe, since the codegen will never have to face an unaligned
724+
// load for these.
725+
//
723726
// Eventually we will have to encode the alignment of the load into our IR
724727
// and have the trace code generator split up the loads where necessary.
725728
// The same will have to be done for store instructions.
726729
if (I->isVolatile() || (I->getOrdering() != AtomicOrdering::NotAtomic) ||
727730
(I->getPointerAddressSpace() != 0) ||
728-
(I->getAlign() != DL.getPrefTypeAlign(I->getType()))) {
731+
(I->getAlign() < DL.getTypeSizeInBits(I->getType()) / 8)) {
729732
serialiseUnimplementedInstruction(I, FLCtxt, BBIdx, InstIdx);
730733
return;
731734
}
@@ -753,8 +756,8 @@ class YkIRWriter {
753756
// accesses.
754757
if (I->isVolatile() || (I->getOrdering() != AtomicOrdering::NotAtomic) ||
755758
(I->getPointerAddressSpace() != 0) ||
756-
(I->getAlign() !=
757-
DL.getPrefTypeAlign(I->getValueOperand()->getType()))) {
759+
(I->getAlign() <
760+
DL.getTypeSizeInBits(I->getValueOperand()->getType()) / 8)) {
758761
serialiseUnimplementedInstruction(I, FLCtxt, BBIdx, InstIdx);
759762
return;
760763
}

0 commit comments

Comments
 (0)