This is an archive of the discontinued LLVM Phabricator instance.

[clang][SVE] Use __inline__ instead of inline in arm_sve.h
ClosedPublic

Authored by joechrisellis on Feb 17 2021, 3:05 AM.

Details

Summary

The inline keyword is not defined in the C89 standard, so source files
that include arm_sve.h will fail compilation if -std=c89 is specified.
For consistency with arm_neon.h, we should use inline instead.

Diff Detail

Event Timeline

joechrisellis created this revision.Feb 17 2021, 3:05 AM
joechrisellis requested review of this revision.Feb 17 2021, 3:05 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 17 2021, 3:05 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
paulwalker-arm accepted this revision.Feb 17 2021, 4:24 AM
This revision is now accepted and ready to land.Feb 17 2021, 4:24 AM
joechrisellis planned changes to this revision.Feb 17 2021, 6:10 AM

Speaking to @DavidTruby about this, it appears that this fix is insufficient -- inline has important semantic meaning in C++ that means that we can't simply omit the keyword here.

The inline keyword bypasses the one-definition rule. If we have a function defined in a header that isn't marked inline, and you include that header in two different source files, then your program is ill formed because it contains 2 definitions of that function. So we have to keep it for C++.

Speaking to @DavidTruby about this, it appears that this fix is insufficient -- inline has important semantic meaning in C++ that means that we can't simply omit the keyword here.

The inline keyword bypasses the one-definition rule. If we have a function defined in a header that isn't marked inline, and you include that header in two different source files, then your program is ill formed because it contains 2 definitions of that function. So we have to keep it for C++.

That makes sense and suggests we're missing some additional C++ testing?

That makes sense and suggests we're missing some additional C++ testing?

Agreed -- this passes all tests at the moment, so we can do better test-wise. The error to do with the one definition rule would crop up at link time, though, so we'd need at least two compilation units to validate this.

paulwalker-arm added a comment.EditedFeb 17 2021, 6:30 AM

One observation is that for arm_neon.h __inline__ is used. So perhaps we can just do likewise and we'll also be consistent across the two ACLE headers?

Use inline instead of inline.

This revision is now accepted and ready to land.Feb 17 2021, 7:37 AM
joechrisellis retitled this revision from [clang][SVE] Remove inline keyword from arm_sve.h to [clang][SVE] Use __inline__ instead of inline in arm_sve.h.Feb 17 2021, 7:38 AM
joechrisellis edited the summary of this revision. (Show Details)
paulwalker-arm accepted this revision.Feb 17 2021, 9:36 AM
This revision was landed with ongoing or failed builds.Feb 18 2021, 9:10 AM
This revision was automatically updated to reflect the committed changes.