This is an archive of the discontinued LLVM Phabricator instance.

[PPC] Fix 32-bit build of libunwind
ClosedPublic

Authored by luporl on May 10 2019, 9:28 AM.

Details

Summary

Clang integrated assembler was unable to build libunwind PPC32 assembly code,
present in functions used to save/restore register context.

This change consists in replacing the assembly style used in libunwind source,
to one that is compatible with both Clang integrated assembler as well as
GNU assembler.

Diff Detail

Repository
rL LLVM

Event Timeline

luporl created this revision.May 10 2019, 9:28 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 10 2019, 9:28 AM
luporl added a subscriber: MaskRay.May 10 2019, 9:41 AM
MaskRay added inline comments.May 10 2019, 7:20 PM
libunwind/src/UnwindRegistersSave.S
559 ↗(On Diff #199029)

Changing the comment marker seems fine from the perspective of consistency.

566 ↗(On Diff #199029)

Nice, if stw r0, 8(r3) is accepted by neither GNU as nor llvm-mc, why was it added in the first place...

Have you considered stw 0, 8(3)? In powerpc assembly, 0 is much more common than %r0.

luporl marked 3 inline comments as done.May 13 2019, 6:57 AM
luporl added inline comments.
libunwind/src/UnwindRegistersSave.S
566 ↗(On Diff #199029)

Yes, I also don't know how the older powerpc assembly in this file was supposed to work...

Personally, I find stw %r0, 8(%r3) easier to read and understand than stw 0, 8(3), because it makes the distinction between registers and immediates clear.
This change is also consistent with powerpc64 code, that uses "%r" for registers.

MaskRay accepted this revision.May 13 2019, 7:18 AM
This revision is now accepted and ready to land.May 13 2019, 7:18 AM
compnerd added inline comments.May 13 2019, 11:10 AM
libunwind/src/UnwindRegistersSave.S
566 ↗(On Diff #199029)

I believe that these were written against the cctools's assembler, not GNU.

mclow.lists accepted this revision.May 13 2019, 11:11 AM
mclow.lists added a subscriber: mclow.lists.

As far as I can tell, this should have no effects - is that correct?
If so, this looks fine to me.

compnerd added inline comments.May 13 2019, 11:20 AM
libunwind/src/assembly.h
32 ↗(On Diff #199029)

Why the removal of this? This is the correct separator IIRC.

luporl marked an inline comment as done.May 13 2019, 11:31 AM

As far as I can tell, this should have no effects - is that correct?
If so, this looks fine to me.

Correct.

luporl marked an inline comment as done.May 13 2019, 11:37 AM
luporl added inline comments.
libunwind/src/assembly.h
32 ↗(On Diff #199029)

Because clang's integrated assembler does not recognize '@' as a separator, but both clang and GNU as recognize ';' as a separator.
Maybe this part was also added when cctools were being used?

Bdragon28 marked an inline comment as done.May 14 2019, 2:50 PM
Bdragon28 added a subscriber: Bdragon28.
Bdragon28 added inline comments.
libunwind/src/assembly.h
32 ↗(On Diff #199029)

Additionally, @ actually means something in PPC64 asm. It's used for indirect references.

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptMay 15 2019, 11:48 PM