This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Diagnose bad 'omp declare variant' that references itself
AcceptedPublic

Authored by mikerice on Feb 16 2022, 2:33 PM.

Details

Summary

When an a variant is specified that is the same as the base function the compiler will end up crashing in CodeGen. Give an error instead.

Diff Detail

Event Timeline

mikerice created this revision.Feb 16 2022, 2:33 PM
mikerice requested review of this revision.Feb 16 2022, 2:33 PM
This revision is now accepted and ready to land.Feb 17 2022, 4:54 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 17 2022, 10:36 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
jdoerfert reopened this revision.Feb 17 2022, 10:47 AM

Why is this supposed to be a user error? I don't remember the standard disallowing this and I can see use cases for this.

This revision is now accepted and ready to land.Feb 17 2022, 10:47 AM

What's the use case? I wasn't aware of any. We saw it from someone who did it accidently and caused the compiler to crash in codegen.

What's the use case? I wasn't aware of any. We saw it from someone who did it accidently and caused the compiler to crash in codegen.

If you have N overloads/variants and you want to pick the original in a certain condition. It might be easier to specify the condition as match clause with a high score rather than avoid other match clauses to apply then. Put differently, if you disallow this you cannot have a "catch all" variant with a low score, e.g., one that issues a compile or runtime failure if picked.
Even if we don't use this now, we still need to stick somewhat to the standard or open an issue there if we think the behavior should be forbidden.