[llvm-commits] [PATCH] va_arg alignment type

David Meyer pdox at google.com
Wed Oct 13 04:52:47 PDT 2010


I've been working on a target with an exotic configuration: 64-bit integers
are 8-byte aligned in memory (in structures and globals), but 4-byte aligned
on the stack.

As a result, a bug emerged with how VAARG alignment is chosen. In
SelectionDAGBuilder.cpp:

void SelectionDAGBuilder::visitVAArg(const VAArgInst &I) {
  const TargetData &TD = *TLI.getTargetData();
  SDValue V = DAG.getVAArg(TLI.getValueType(I.getType()), getCurDebugLoc(),
                           getRoot(), getValue(I.getOperand(0)),
                           DAG.getSrcValue(I.getOperand(0)),
                           TD.getABITypeAlignment(I.getType()));
  setValue(&I, V);
  DAG.setRoot(V.getValue(1));
}

This invokes TD.getABITypeAlignment() to get the alignment for va_arg.
However, va_arg values actually reside on the stack.

Attached is a patch which changes the above code to use
TD.getCallFrameTypeAlignment() instead. This change fixed the problem with
my exotic configuration, however it may also have ramifications for other
architectures.

Could someone with more general target knowledge comment on the correctness
of this change?

Thank you,
  David Meyer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20101013/9ee6f256/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: va-arg-alignment.patch
Type: application/octet-stream
Size: 682 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20101013/9ee6f256/attachment.obj>


More information about the llvm-commits mailing list