<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - Missing LValueToRValue casts for use of __builtin_shufflevector in function template instantiations"
href="https://llvm.org/bugs/show_bug.cgi?id=27981">27981</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Missing LValueToRValue casts for use of __builtin_shufflevector in function template instantiations
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>thonerma@synopsys.com
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvm-bugs@lists.llvm.org, sig-rnd-sat-clang-bugs@synopsys.com
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>The following test case demonstrates that implicit LValueToRValue casts are
getting lost when instantiating function templates that include invocations of
__builtin_shufflevector.
In the annotated AST dump that follows, the locations noted with #2.1 and #2.2
identify where the missing casts should be. The locations noted with #1.1,
#1.2, #3.1, and #3.2 identify where expected casts are present for comparison.
$ cat t.cpp
typedef char v4 __attribute__((__vector_size__(4)));
template<typename>
void tf(v4 v) {
__builtin_shufflevector(v, v, 0, 1, 2, 3);
}
auto x = tf<int>;
void tf(v4 v) {
__builtin_shufflevector(v, v, 0, 1, 2, 3);
}
$ clang --version
clang version 3.9.0 (trunk 271472)
...
$ clang -Xclang -ast-dump -c -std=c++11 -w t.cpp
...
# Here we see the function template definition with implicit LValueToRValue
# casts present:
|-FunctionTemplateDecl 0x89d7348 <line:3:1, line:6:1> line:4:6 tf
| |-TemplateTypeParmDecl 0x89d70b8 <line:3:10> col:10 typename
| |-FunctionDecl 0x89d72a0 <line:4:1, line:6:1> line:4:6 tf 'void (v4)'
| | |-ParmVarDecl 0x89d71a0 <col:9, col:12> col:12 referenced v
'v4':'__attribute__((__vector_size__(4 * sizeof(char)))) char'
| | `-CompoundStmt 0x89d7760 <col:15, line:6:1>
| | `-ShuffleVectorExpr 0x89d7708 <line:5:5, col:45>
'v4':'__attribute__((__vector_size__(4 * sizeof(char)))) char'
#1.1: Implicit LValueToRValue cast present:
| | |-ImplicitCastExpr 0x89d76d8 <col:29>
'v4':'__attribute__((__vector_size__(4 * sizeof(char)))) char' <LValueToRValue>
| | | `-DeclRefExpr 0x89d7570 <col:29>
'v4':'__attribute__((__vector_size__(4 * sizeof(char)))) char' lvalue ParmVar
0x89d71a0 'v' 'v4':'__attribute__((__vector_size__(4 * sizeof(char)))) char'
#1.2: Implicit LValueToRValue cast present:
| | |-ImplicitCastExpr 0x89d76f0 <col:32>
'v4':'__attribute__((__vector_size__(4 * sizeof(char)))) char' <LValueToRValue>
| | | `-DeclRefExpr 0x89d7598 <col:32>
'v4':'__attribute__((__vector_size__(4 * sizeof(char)))) char' lvalue ParmVar
0x89d71a0 'v' 'v4':'__attribute__((__vector_size__(4 * sizeof(char)))) char'
| | |-IntegerLiteral 0x89d75c0 <col:35> 'int' 0
| | |-IntegerLiteral 0x89d75e0 <col:38> 'int' 1
| | |-IntegerLiteral 0x89d7600 <col:41> 'int' 2
| | `-IntegerLiteral 0x89d7620 <col:44> 'int' 3
# Here we see the instantiated function template specialization definition
# with implicit LValueToRValue casts missing:
| `-FunctionDecl 0x89d7ae8 <line:4:1, line:6:1> line:4:6 used tf 'void (v4)'
| |-TemplateArgument type 'int'
| |-ParmVarDecl 0x89d7a60 <col:9, col:12> col:12 used v
'v4':'__attribute__((__vector_size__(4 * sizeof(char)))) char'
| `-CompoundStmt 0x89e05c0 <col:15, line:6:1>
| `-ShuffleVectorExpr 0x89e0568 <line:5:5, col:45>
'v4':'__attribute__((__vector_size__(4 * sizeof(char)))) char'
#2.1: Implicit LValueToRValue cast missing:
| |-DeclRefExpr 0x89e0480 <col:29> 'v4':'__attribute__((__vector_size__(4
* sizeof(char)))) char' lvalue ParmVar 0x89d7a60 'v'
'v4':'__attribute__((__vector_size__(4 * sizeof(char)))) char'
#2.2: Implicit LValueToRValue cast missing:
| |-DeclRefExpr 0x89e04a8 <col:32> 'v4':'__attribute__((__vector_size__(4
* sizeof(char)))) char' lvalue ParmVar 0x89d7a60 'v'
'v4':'__attribute__((__vector_size__(4 * sizeof(char)))) char'
| |-IntegerLiteral 0x89d75c0 <col:35> 'int' 0
| |-IntegerLiteral 0x89d75e0 <col:38> 'int' 1
| |-IntegerLiteral 0x89d7600 <col:41> 'int' 2
| `-IntegerLiteral 0x89d7620 <col:44> 'int' 3
...
# For comparison, here is the AST emitted for a non-template function that
# invokes __builtin_shufflevector. The expected implicit LValueToRValue
# casts are present here.
`-FunctionDecl 0x89d7f60 <line:9:1, line:11:1> line:9:6 tf 'void (v4)'
|-ParmVarDecl 0x89d7ed8 <col:9, col:12> col:12 used v
'v4':'__attribute__((__vector_size__(4 * sizeof(char)))) char'
`-CompoundStmt 0x89e0460 <col:15, line:11:1>
`-ShuffleVectorExpr 0x89e0408 <line:10:5, col:45>
'v4':'__attribute__((__vector_size__(4 * sizeof(char)))) char'
#3.1: Implicit LValueToRValue cast present:
|-ImplicitCastExpr 0x89e03d8 <col:29>
'v4':'__attribute__((__vector_size__(4 * sizeof(char)))) char' <LValueToRValue>
| `-DeclRefExpr 0x89e0298 <col:29> 'v4':'__attribute__((__vector_size__(4
* sizeof(char)))) char' lvalue ParmVar 0x89d7ed8 'v'
'v4':'__attribute__((__vector_size__(4 * sizeof(char)))) char'
#3.2: Implicit LValueToRValue cast present:
|-ImplicitCastExpr 0x89e03f0 <col:32>
'v4':'__attribute__((__vector_size__(4 * sizeof(char)))) char' <LValueToRValue>
| `-DeclRefExpr 0x89e02c0 <col:32> 'v4':'__attribute__((__vector_size__(4
* sizeof(char)))) char' lvalue ParmVar 0x89d7ed8 'v'
'v4':'__attribute__((__vector_size__(4 * sizeof(char)))) char'
|-IntegerLiteral 0x89e02e8 <col:35> 'int' 0
|-IntegerLiteral 0x89e0308 <col:38> 'int' 1
|-IntegerLiteral 0x89e0328 <col:41> 'int' 2
`-IntegerLiteral 0x89e0348 <col:44> 'int' 3</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>