Yes, we can do this. I wanted to do like this, but I thought it won't
be accepted as a kind of a hack again. We're passing Type* as Expr*. I
tried to avoid such reinterpret castings. But if this solution is
acceptable, I'll rework the patch in a few minutes.
Best regards,
Alexey Bataev
=============
Software Engineer
Intel Compiler Team
22 Июль 2014 г. 10:58:11, Richard Smith писал:
On Mon, Jul 21, 2014 at 10:58 PM, Bataev, Alexey <[email protected]
<mailto:[email protected]>> wrote:
Richard, yes, I understood that. We have troubles in CodeGen in
this case. Yes, I can call getSizeExpr() for VariableArrayType, by
it is impossible to get llvm::Value* for the expression returned
by getSizeExpr() in lambda operator().
You can do this in exactly the same way you do it in your current
patch; see attached patch for example.
This value is calculated in parent function for lambda expr and we
have to pass it somehow to lambda. Passing VariableArrayType* does
not allow us to get an access to this value.
We must not recalculate the value of expression from
getSizeExpr(), we must use the value, calculated in parent
function. That's why it is not enough just to pass
VariableArrayType*, also we need to pass llvm::Value* for
getSizeExpr(), calculated in parent function.
Best regards,
Alexey Bataev
=============
Software Engineer
Intel Compiler Team
22 Июль 2014 г. 9:41:43, Richard Smith писал:
On Mon, Jul 21, 2014 at 10:14 PM, Bataev, Alexey
<[email protected] <mailto:[email protected]>
<mailto:[email protected] <mailto:[email protected]>>>
wrote:
Richard, I don't think this is possible. If we storing
VariableLengthArray* on FieldDecl, then in Lambda operator
we can
access VariableLengthArray->____getSizeExpr(). But! We
won't be able
to get the llvm::Value* for this
VariableLengthArray->____getSizeExpr(), calculated in another
function. We should pass this llvm::Value* as a member of
RecordDecl for LambdaExpr! Here is a scheme:
foo() {
int vla[n+m];
....
some_lambda {vla....;}
....
}
What we have in CodeGen for this example:
CodeGenFunction(foo), llvm::DenseMap<const Expr*,
llvm::Value*>
VLASizeMap[n+m]=value; VLASizeMap stores pre-calculated
size of
each VLA.
{
FD->field_for_m+n_expr = (int [n+m]*)0;
CodeGenFunction CGF(some_lambda.operator(), FD);
}
CodeGenFunction(some_lambda.____operator()),
llvm::DenseMap<const
Expr*, llvm::Value*> VLASizeMap[n+m]=????? - llvm::Value* for
'n+m' is not captured here, we don't have an access to
'value',
calculated in CodeGenFunction(foo) for expression 'n+m'.
To solve this problem we can try to capture 2 fields
instead - one
for VariableLengthArray*, and another one for llvm::Value*
calculated for VariableLengthArray->____getSizeExpr().
I'm sorry, I still think we're miscommunicating. What I'm
suggesting
is a mechanical transformation: store the VariableArrayType*
on the
FieldDecl, and then when you need the size expression that you're
currently storing there, call getSizeExpr() on the type.
Best regards,
Alexey Bataev
=============
Software Engineer
Intel Compiler Team
22 Июль 2014 г. 8:57:54, Richard Smith писал:
On Mon, Jul 21, 2014 at 5:43 AM, Alexey Bataev
<[email protected] <mailto:[email protected]>
<mailto:[email protected] <mailto:[email protected]>>
<mailto:[email protected]
<mailto:[email protected]> <mailto:[email protected]
<mailto:[email protected]>>>__>
wrote:
Updated version after last review. Unfortunately,
I don't
think it
is possible to pass captured expression as a
VariableLengthArray
*. I have to capture expr of VariableLengthArray * and
then cast
it to SizeExpr->getType() type to make lambda
capture this
type,
not VariableLengthArray *. I have to pass actual
value of
SizeExpr
to the Lambda in this field, because it is defined
only in
calling
function and in Lambda it can be received only in
one of
captured
fields.
I don't understand what you're saying. What I'm
suggesting is
storing
the VariableLengthArray* in the InitializerOrBitWidth
field on
FieldDecl, instead of storing the array bound there.
http://reviews.llvm.org/D4368
Files:
include/clang/AST/Decl.h
include/clang/AST/____LambdaCapture.h
include/clang/Basic/____DiagnosticSemaKinds.td
lib/AST/Decl.cpp
lib/AST/Expr.cpp
lib/AST/ExprCXX.cpp
lib/AST/StmtPrinter.cpp
lib/AST/StmtProfile.cpp
lib/CodeGen/CGDebugInfo.cpp
lib/CodeGen/CGExprCXX.cpp
lib/CodeGen/CodeGenFunction.____cpp
lib/Sema/SemaDecl.cpp
lib/Sema/SemaExpr.cpp
lib/Sema/TreeTransform.h
test/CodeGenCXX/instantiate-____typeof-vla.cpp
test/SemaTemplate/instantiate-____typeof.cpp
tools/libclang/IndexBody.cpp
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits