This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] [Clang] Fix alignment of 128-bit floating types
ClosedPublic

Authored by qiucf on Nov 17 2020, 1:15 AM.

Details

Summary

According to ELF v2 ABI, both IEEE 128-bit and IBM extended floating point variables should be quad-word (16 bytes) aligned. Previously, only vector types are considered aligned as quad-word on Power.

Without this fix, IEEE 128-bit fp will be passed incorrectly in va_arg cases.

(the patch is not patchable since I generated it for easier review, the case is a new file)

Diff Detail

Event Timeline

qiucf created this revision.Nov 17 2020, 1:15 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 17 2020, 1:15 AM
qiucf requested review of this revision.Nov 17 2020, 1:15 AM
qiucf updated this revision to Diff 305692.Nov 17 2020, 1:22 AM

Use another branch

rjmccall accepted this revision.Nov 18 2020, 7:37 PM

I assume this has always been taken care of properly in the backend, so this is just a fix for va_arg treatment? If so, LGTM.

This revision is now accepted and ready to land.Nov 18 2020, 7:37 PM

I assume this has always been taken care of properly in the backend, so this is just a fix for va_arg treatment? If so, LGTM.

Yes. That's just fix for va_arg. Thanks!

This revision was automatically updated to reflect the committed changes.

Reverting this patch makes va_arg with the default 128-bit (double-double) long double work again:

#include <stdarg.h>
void abort(void);

void foo(int x, ...) {
  va_list ap;
  va_start(ap, x);
  long double ans = va_arg(ap, long double);
  if (ans != 42.L) abort();
}

int main(void) {
  foo(0, 42.L);
}

This patch caused the above to abort.

qiucf added a comment.Dec 2 2020, 1:05 AM

The regression should be fixed in rG3fca6a7844b5