[cfe-dev] Using both OpenCL and GCC vectors

Anastasia Stulova via cfe-dev cfe-dev at lists.llvm.org
Fri Feb 5 10:44:44 PST 2016


I guess another option would be to mangle differently OpenCL and GCC vectors. Not sure what would be better though...

Cheers,
Anastasia

From: cfe-dev [mailto:cfe-dev-bounces at lists.llvm.org] On Behalf Of Yung, Douglas via cfe-dev
Sent: 03 February 2016 03:33
To: cfe-dev at lists.llvm.org
Subject: [cfe-dev] Using both OpenCL and GCC vectors

Hi,

In our testing, we discovered a regression in 3.8 when trying to use both OpenCL and GCC vectors in the same program. Consider the following code:

template <typename alpha>
static void foo() {}

void bar() {
  foo<float __attribute__((__vector_size__(16)))>();
  foo<float __attribute__((ext_vector_type(4)))>();
}

In 3.7, the code compiled without any errors, but in 3.8 it fails to compile. The problem is that clang considers GCC and OpenCL vectors to be unique types, but since they mangle identically, the compiler instantiates two versions of foo which are identical and emits an error:

repro.cpp:2:13: error: definition with same mangled name as another definition
static void foo() {}
            ^
repro4.cpp:2:13: note: previous definition is here
1 error generated.

The error is unfortunately not very helpful and was filed as PR25343. However, we feel that the compiler could be smarter in these cases. For example, the compiler could recognize that it is generating the same function when instantiating the second instance of foo and reuse the first one instead of creating another one. This would prevent the creation of two identically mangled names which caused the error seen above. Or perhaps the compiler could be smarter and when it encounters the second instantiation of foo, it would issue an error at that point with a useful diagnostic.

Thoughts?

Douglas Yung
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160205/cc153890/attachment.html>


More information about the cfe-dev mailing list