This is an archive of the discontinued LLVM Phabricator instance.

[OpenCL][PR48896] Fix default address space in template argument deduction
ClosedPublic

Authored by Anastasia on Jan 28 2021, 8:26 AM.

Details

Summary

When deducing a reference type for forwarding references prevent adding default address space of a template argument if it is given.

In OpenCL all parameters are in private address space and therefore when we initialize a forwarding reference with a parameter we should just inherit the address space from it i.e. keep __private instead of __generic (see test case).

Diff Detail

Event Timeline

Anastasia created this revision.Jan 28 2021, 8:26 AM
Anastasia requested review of this revision.Jan 28 2021, 8:26 AM
Anastasia updated this revision to Diff 320484.Feb 1 2021, 8:47 AM
Anastasia retitled this revision from [OpenCL][PR48896] Add default address space in template argument deduction only if missing to [OpenCL][PR48896] Fix default address space in template argument deduction.
Anastasia edited the summary of this revision. (Show Details)
Anastasia added a subscriber: cfe-commits.

Added test.

rjmccall accepted this revision.Feb 3 2021, 2:43 PM

LGTM.

This revision is now accepted and ready to land.Feb 3 2021, 2:43 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 4 2021, 5:53 AM
bader added a subscriber: bader.Mar 11 2021, 8:42 PM
bader added inline comments.
clang/test/SemaOpenCLCXX/address-space-templates.cl
60

This check fails on 32-bit Windows platform where compiler adds __attribute__((thiscall)) both constructor and call operator.

Something like this should fix the problem:

// CHECK: |-CXXConstructorDecl {{.*}} rep 'void (const __generic rep &__private){{.*}} __generic'
// CHECK: CXXMethodDecl {{.*}} operator() 'void (__private int &__private){{.*}} const __generic'
Anastasia added inline comments.
clang/test/SemaOpenCLCXX/address-space-templates.cl
60