Page MenuHomePhabricator

[Clang] [PowerPC] Emit module flag for current float abi
Needs ReviewPublic

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

Details

Reviewers
nemanjai
shchenz
uweigand
MaskRay
jdoerfert
jsji
Group Reviewers
Restricted Project
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.

Note: This patch will break 50+ more LIT tests in clang/test/OpenMP. They're all trivial changes since only the referenced metadata numbers are changed. They're not included in this review since it's quite large so that browser cannot load them easily.

Diff Detail

Unit TestsFailed

TimeTest
60 msx64 debian > LLVM.Bindings/Go::go.test
Script: -- : 'RUN: at line 1'; /var/lib/buildkite-agent/builds/llvm-project/build/bin/llvm-go go=/usr/bin/go test llvm.org/llvm/bindings/go/llvm

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