This is an archive of the discontinued LLVM Phabricator instance.

[OPENMP] Eliminate extra set of simd variant function attribute.
ClosedPublic

Authored by jyu2 on Mar 23 2022, 12:00 PM.

Details

Summary

Current clang generates extra set of simd variant function attribute
with extra 'v' encoding.
For example:
_ZGVbN2vZ5add_1Pf vs _ZGVbN2vvZ5add_1Pf
The problem is due to declaration of ParamAttrs following:

llvm::SmallVector<ParamAttrTy, 8> ParamAttrs(ParamPositions.size());

where ParamPositions.size() is grown after following assignment:

Pos = ParamPositions[PVD];

So the PVD is not find in ParamPositions.

The problem is ParamPositions need to set for each FD decl. To fix this

Move ParamPositions's init inside while loop for each FD.

Diff Detail

Event Timeline

jyu2 created this revision.Mar 23 2022, 12:00 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 23 2022, 12:00 PM
jyu2 requested review of this revision.Mar 23 2022, 12:00 PM

If ParamPositions grows, it means that the item is not found. Is it correct behavior if the compiler inserts new item in the ParamPositions map?

jyu2 added a comment.Mar 23 2022, 2:22 PM

If ParamPositions grows, it means that the item is not found. Is it correct behavior if the compiler inserts new item in the ParamPositions map?

I see. Thanks! Then it seems ParamPositions need to be set for each function decl otherwise PVD can not find.

jyu2 updated this revision to Diff 417746.Mar 23 2022, 2:27 PM
jyu2 edited the summary of this revision. (Show Details)
ABataev added inline comments.Mar 24 2022, 5:47 AM
clang/lib/CodeGen/CGOpenMPRuntime.cpp
11959

I would also recommend to replace all operator [] calls to something that does not modify the map, like find.

jyu2 updated this revision to Diff 417944.Mar 24 2022, 8:59 AM

Address Alexey's comment.

ABataev added inline comments.Mar 24 2022, 9:07 AM
clang/lib/CodeGen/CGOpenMPRuntime.cpp
11963

Better to use count() or contain() (do not remember which one is defined for DenseMap), also add messages to asserts.

ABataev added inline comments.Mar 24 2022, 9:08 AM
clang/lib/CodeGen/CGOpenMPRuntime.cpp
11963–11964

Or, if you already using find, better to do something like:

auto It = ParamPositions.find(PVD);
assert(It != ParamPositions.end() && "...");
Pos = It->second;
jyu2 updated this revision to Diff 417981.Mar 24 2022, 10:32 AM

Address Alexey comment.

This revision is now accepted and ready to land.Mar 24 2022, 10:37 AM
This revision was automatically updated to reflect the committed changes.
jyu2 added a comment.Mar 24 2022, 1:47 PM

LG

Thank you so much Alexey.

clang/lib/CodeGen/CGOpenMPRuntime.cpp
11959

How about adding assert? Thanks.