This is an archive of the discontinued LLVM Phabricator instance.

[Clang] [PowerPC] Emit module flag for current float abi
ClosedPublic

Authored by qiucf on Dec 19 2021, 9:34 PM.

Details

Summary

This is part of the efforts adding .gnu_attribute support for PowerPC. In Clang, an extra metadata field will be added as float-abi to show current long double format. So backend can emit .gnu_attribute section data from this metadata.

To avoid breaking existing behavior, the module metadata will only be emitted when this module makes use of long double.

Diff Detail

Event Timeline

qiucf created this revision.Dec 19 2021, 9:34 PM
qiucf requested review of this revision.Dec 19 2021, 9:34 PM
Herald added a project: Restricted Project. · View Herald Transcript

This is part of the efforts adding .gnu_attribute support for PowerPC. In Clang, an extra metadata field will be added as float-abi to show current long double format. So backend can emit .gnu_attribute section data from this metadata.

How does .gnu_attribute work with the metadata?

clang/test/CodeGen/ppc64-float-abi-attr.c
10

![[#]]

qiucf added a comment.Dec 19 2021, 9:45 PM

This is part of the efforts adding .gnu_attribute support for PowerPC. In Clang, an extra metadata field will be added as float-abi to show current long double format. So backend can emit .gnu_attribute section data from this metadata.

How does .gnu_attribute work with the metadata?

Planned way to do is check the module flag in ASM printer, like

if (flt == "doubledouble")
  OutStreamer->emitGNUAttribute(4, 5);
else if (flt == "ieeequad")
  OutStreamer->emitGNUAttribute(4, 13);
else if (flt == "ieeedouble")
  OutStreamer->emitGNUAttribute(4, 9);

Currently this doesn't look like the most elegant way, and doesn't fully match behavior of GCC. (In GCC, if no floating operations exist, the attributes won't be generated) But since the floating abi option applies to the whole module, adding them to module flags are more reasonable than function attributes.

We should not be emitting the attribute in modules that do not have any use of long double.

We should not be emitting the attribute in modules that do not have any use of long double.

Right, otherwise it would be a bit unfortunate that a library not using long double has to be compiled differently to use ThinLTO with other programs, since the module flags metadata's behavior is Error (1).

qiucf updated this revision to Diff 397443.Jan 4 2022, 6:41 PM

Only emit the flags when any instance of long double is used.

jsji resigned from this revision.Jun 2 2022, 7:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 2 2022, 7:49 AM
Herald added a subscriber: StephenFan. · View Herald Transcript
tuliom added a subscriber: tuliom.Jun 12 2023, 5:38 AM
qiucf updated this revision to Diff 530843.Jun 13 2023, 3:12 AM
qiucf marked an inline comment as done.
qiucf edited the summary of this revision. (Show Details)
qiucf removed a reviewer: jsji.

Gentle ping?

nemanjai accepted this revision.Sep 21 2023, 1:10 PM

LGTM. Thanks for reviving this patch.

This revision is now accepted and ready to land.Sep 21 2023, 1:10 PM
This revision was automatically updated to reflect the committed changes.