This is an archive of the discontinued LLVM Phabricator instance.

[XCOFF][AIX] Generate LSDA data and compact unwind section on AIX
ClosedPublic

Authored by jasonliu on Nov 13 2020, 12:54 PM.

Details

Summary

AIX uses the existing EH infrastructure in clang and llvm.
The major differences would be

  1. AIX do not have CFI instructions.
  2. AIX uses a new personality routine, named __xlcxx_personality_v1. It doesn't use the GCC personality rountine, because the interoperability is not there yet on AIX.
  3. AIX do not use eh_frame sections. Instead, it would use a eh_info section (compat unwind section) to store the information about personality routine and LSDA data address.

Diff Detail

Event Timeline

jasonliu created this revision.Nov 13 2020, 12:54 PM
jasonliu requested review of this revision.Nov 13 2020, 12:54 PM
daltenty added inline comments.Nov 30 2020, 11:04 AM
llvm/lib/CodeGen/AsmPrinter/AIXException.cpp
49

nit: Why not just call getPointerSize() instead? (getPointerSizeInBits() does getPointerSize()*8 under the hood anyway)

daltenty added inline comments.Nov 30 2020, 11:41 AM
llvm/lib/MC/MCObjectFileInfo.cpp
889

I think this may have been discussed elsewhere, but why do we want to emit this as a RW section?

jasonliu added inline comments.Nov 30 2020, 1:58 PM
llvm/lib/MC/MCObjectFileInfo.cpp
889

Yes, this has been discussed before. And it's a good question.
If we emit this as an RO section, then we could not put

.vbyte	4, GCC_except_table1
.vbyte	4, __xlcxx_personality_v1[DS]

into this csect directly.
If we do that, we would hit linker error during link time. It seems that for read only csects (RO, PR mapping classes), we could not have relocation types like R_POS or R_NEG because the result coming out of it is not link-time constant. And the relocation types in read only csects needs to be link time constant.

Extra work (both compiler and runtime) will be needed if we want to make this RO.

daltenty added inline comments.Nov 30 2020, 6:33 PM
llvm/lib/MC/MCObjectFileInfo.cpp
889

Thanks for clarifying. I guess we'd presumably need to add the TOC indirections to get to the LSDA and personality routine's function descriptor, similar to elsewhere.

Since this structure is version'd, seems like we have the flexibility to defer that work, so I guess that's OK.

  1. AIX uses a new personality routine, named __xlcxx_personality_v1. It doesn't use the GCC personality rountine, because the intractability is not there yet on AIX.

@jasonliu, is "intractability" a typo/autocorrect problem?

jasonliu added inline comments.Nov 30 2020, 8:46 PM
llvm/lib/MC/MCObjectFileInfo.cpp
889

add the TOC indirections to get to the LSDA and personality routine's function descriptor

Yep, that's one potential way to solve it. The downside of it would be

  1. We might have more TC entries than we desired.
  2. A small performance penalty to pay for the extra indirection. (But since we already on the EH path, and it's slow anyway, might not be that big of a deal).

But as you already mentioned, we don't have to solve this issue right now.

jasonliu edited the summary of this revision. (Show Details)Nov 30 2020, 8:47 PM
  1. AIX uses a new personality routine, named __xlcxx_personality_v1. It doesn't use the GCC personality rountine, because the intractability is not there yet on AIX.

@jasonliu, is "intractability" a typo/autocorrect problem?

Yep. Fixed!

jasonliu updated this revision to Diff 308653.Dec 1 2020, 7:34 AM

Address comment.

daltenty added inline comments.Dec 1 2020, 8:43 AM
llvm/lib/CodeGen/AsmPrinter/AIXException.cpp
68

This logic seems very similar to the base class.

The pattern there and in other instance of EHStreamer seems to be to make these queries in beginFunction, store the results in a member and just early exit if we have nothing to emit in endFunction, etc. Is that something we should be doing here? (e.g. presumably the traceback emission will want to know if we plan to emit anything so it can emit the appropriate info)

jasonliu added inline comments.Dec 1 2020, 9:16 AM
llvm/lib/CodeGen/AsmPrinter/AIXException.cpp
68

I agree that this is a query that we want to share with the traceback table emission.
Presumably, we need to do the traceback table emission somewhere in PPCAIXAsmPrinter.
So that means we would need to have a query that could accessible from PPCAIXAsmPrinter and here.
And there are other EHStreamer that have similar queries (but not all of them), so this makes it trickier to get it right if we want to do it for all platforms.
I was hoping to address this issue when we actually do the traceback table emission for EH info so that we could keep the scope of the patch reasonable.

daltenty accepted this revision.Dec 1 2020, 9:53 AM

LGTM

llvm/lib/CodeGen/AsmPrinter/AIXException.cpp
68

Thanks, I think that helps explain the structure here. This should be amenable to later refactoring, so that sounds good for now.

This revision is now accepted and ready to land.Dec 1 2020, 9:53 AM
llvm/test/CodeGen/PowerPC/aix-exception.ll
108–109

Is there a plan to update the annotation output here?

llvm/lib/CodeGen/AsmPrinter/AIXException.cpp
35

Typo: missing space.

jasonliu updated this revision to Diff 308752.Dec 1 2020, 1:33 PM

Address comments.

jasonliu marked 2 inline comments as done.Dec 1 2020, 1:34 PM
jasonliu added inline comments.
llvm/test/CodeGen/PowerPC/aix-exception.ll
108–109

updated to address comment.

LGTM; thanks.

llvm/test/CodeGen/PowerPC/aix-exception.ll
108–109

Thanks.

Herald added a project: Restricted Project. · View Herald TranscriptDec 2 2020, 10:43 AM