Page MenuHomePhabricator

[OpenMP] Context selector extensions for return value overloading
ClosedPublic

Authored by jdoerfert on Aug 12 2020, 11:30 PM.

Details

Summary

This extension allows to declare variants in between `omp begin/end
declare variant` that do not match the type of the existing function
with that name. Without this extension we would not find a base function
(with a compatible type), therefore create a new one, which would
cause conflicting declarations. With this extension we will not create
"missing" base functions, which basically renders these specializations
harmless. They will be generated but never called.

Diff Detail

Event Timeline

jdoerfert created this revision.Aug 12 2020, 11:30 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald Transcript
jdoerfert requested review of this revision.Aug 12 2020, 11:31 PM
ABataev added inline comments.Aug 13 2020, 9:23 AM
clang/lib/Sema/SemaOpenMP.cpp
5926

Does the user of this function expect that BaseFD can be nullptr after this change?

jdoerfert added inline comments.Aug 13 2020, 12:18 PM
clang/lib/Sema/SemaOpenMP.cpp
5926

It was always OK to return a nullptr, I think.
The call site is here https://github.com/llvm/llvm-project/blob/master/clang/lib/Sema/SemaDecl.cpp#L13765

The important thing is that we mangle the name, but not returning a BaseFD will simply not add an OMPDeclareVariantAttr to anything, making this variant unused code.

If I recall correctly, &foo with variants of foo returns a pointer to the base. If we have no base, and disable_implicit_base, what does &foo yield? It should probably be a compilation error with some descriptive message

If I recall correctly, &foo with variants of foo returns a pointer to the base.

Correct.

If we have no base, and disable_implicit_base, what does &foo yield? It should probably be a compilation error with some descriptive message

undefined symbol foo, or whatever message we emit if you use a variable that doesn't exist. A function definition bar inside of begin/end declare variant is *not* a function bar. It is a variant of a base function that exists or that we assume to exist (=implicitly declare).

JonChesterfield accepted this revision.Aug 16 2020, 11:11 AM

Link error seems reasonable to me. Thanks

This revision is now accepted and ready to land.Aug 16 2020, 11:11 AM