Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit 301c4da

Browse files
committed
Remove extra vararg store alignment.
kripken added this in 6198caf but it's not needed anymore (and was incorrect): the code was putting varargs on the stack as a packed struct which caused misaligned reads and writes, I fixed the issue by making the struct non-packed and using the target's prefered alignment for each element instead. The alloca should be aligned to the target's preference too, so everything should now be neatly aligned. This pass runs pre-opt, so the optimizer can figure out the alignment of all the loads and stores and foster further harmony in the memory.
1 parent efe8231 commit 301c4da

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

lib/Transforms/NaCl/ExpandVarArgs.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,8 @@ static bool ExpandVarArgCall(Module *M, InstType *Call, DataLayout *DL) {
243243
IRB.CreateMemCpy(Ptr, Arg, DL->getTypeAllocSize(
244244
Arg->getType()->getPointerElementType()),
245245
/*Align=*/1);
246-
else {
247-
StoreInst *S = IRB.CreateStore(Arg, Ptr);
248-
S->setAlignment(4); // EMSCRIPTEN: pnacl stack is only 4-byte aligned
249-
}
246+
else
247+
IRB.CreateStore(Arg, Ptr);
250248
++Index;
251249
}
252250

0 commit comments

Comments
 (0)