This is an archive of the discontinued LLVM Phabricator instance.

[Clang][LoongArch] Fix ABI handling of empty structs in C++ to match GCC behaviour
ClosedPublic

Authored by SixWeining on Jul 24 2023, 6:04 AM.

Details

Summary

GCC doesn't ignore non-zero-length array of empty structures in C++
while clang does. What this patch did is to match GCC's behaviour
although this rule is not documented in psABI.

Similar to D142327 for RISCV. Depends on D142327.

Diff Detail

Event Timeline

SixWeining created this revision.Jul 24 2023, 6:04 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 24 2023, 6:04 AM
SixWeining requested review of this revision.Jul 24 2023, 6:04 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 24 2023, 6:04 AM

Ooops. These corner cases are really annoying.

I think I should try make check-gcc check-g++ RUNTESTFLAGS='ALT_CC_UNDER_TEST=clang ALT_CXX_UNDER_TEST=clang++ compat.exp' in GCC test suite...

xry111 accepted this revision.Jul 24 2023, 6:12 AM

The change itself LGTM.

This revision is now accepted and ready to land.Jul 24 2023, 6:12 AM
xen0n accepted this revision.Jul 24 2023, 6:15 AM

So this one is different than D151298 (I'm very glad that those registers are ultimately saved btw), and solves a real problem. Thanks for the timely catch before LLVM 17 ;-)

This seems to not build: http://45.33.8.238/linux/113405/step_4.txt (?)

Thanks, I have reverted.

SixWeining reopened this revision.Jul 25 2023, 7:32 PM
This revision is now accepted and ready to land.Jul 25 2023, 7:32 PM
SixWeining updated this revision to Diff 547711.Aug 7 2023, 4:16 AM

add an extra check for when a candidate from detectFAREligibleStructHelper may not be valid