[llvm-bugs] [Bug 27981] New: Missing LValueToRValue casts for use of __builtin_shufflevector in function template instantiations
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Jun 2 08:07:35 PDT 2016
https://llvm.org/bugs/show_bug.cgi?id=27981
Bug ID: 27981
Summary: Missing LValueToRValue casts for use of
__builtin_shufflevector in function template
instantiations
Product: clang
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: thonerma at synopsys.com
CC: dgregor at apple.com, llvm-bugs at lists.llvm.org,
sig-rnd-sat-clang-bugs at synopsys.com
Classification: Unclassified
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
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160602/05bf4bfd/attachment.html>
More information about the llvm-bugs
mailing list