[cfe-commits] r159161 - in /cfe/trunk: lib/AST/ExprConstant.cpp test/SemaCXX/constexpr-many-arguments.cpp
Chandler Carruth
chandlerc at google.com
Mon Jun 25 14:28:00 PDT 2012
On Mon, Jun 25, 2012 at 2:26 PM, Chandler Carruth <chandlerc at google.com>wrote:
> On Mon, Jun 25, 2012 at 2:21 PM, Eli Friedman <eli.friedman at gmail.com>wrote:
>
>> Author: efriedma
>> Date: Mon Jun 25 16:21:08 2012
>> New Revision: 159161
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=159161&view=rev
>> Log:
>> Use std::map instead of llvm::DenseMap because we rely on the stability
>> of references to values in these maps. PR13197.
>>
>
> Would it be better to use a vector for storage and a densemap of
> pointer->pointer?
>
Obviously, a vector doesn't work for the same reason a densemap doesn't...
However, we could model a reference as a stable index into a vector, or use
a deque-like storage system, potentially even a bumpptrallocator...
>
> In the past this has been somewhat performance sensitive.
>
>
>>
>> Added:
>> cfe/trunk/test/SemaCXX/constexpr-many-arguments.cpp
>> Modified:
>> cfe/trunk/lib/AST/ExprConstant.cpp
>>
>> Modified: cfe/trunk/lib/AST/ExprConstant.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=159161&r1=159160&r2=159161&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/AST/ExprConstant.cpp (original)
>> +++ cfe/trunk/lib/AST/ExprConstant.cpp Mon Jun 25 16:21:08 2012
>> @@ -287,7 +287,9 @@
>> /// parameters' function scope indices.
>> const APValue *Arguments;
>>
>> - typedef llvm::DenseMap<const Expr*, APValue> MapTy;
>> + // Note that we intentionally use std::map here so that references to
>> + // values are stable.
>> + typedef std::map<const Expr*, APValue> MapTy;
>> typedef MapTy::const_iterator temp_iterator;
>> /// Temporaries - Temporary lvalues materialized within this stack
>> frame.
>> MapTy Temporaries;
>> @@ -361,7 +363,9 @@
>> /// NextCallIndex - The next call index to assign.
>> unsigned NextCallIndex;
>>
>> - typedef llvm::DenseMap<const OpaqueValueExpr*, APValue> MapTy;
>> + // Note that we intentionally use std::map here so that references
>> + // to values are stable.
>> + typedef std::map<const OpaqueValueExpr*, APValue> MapTy;
>> /// OpaqueValues - Values used as the common expression in a
>> /// BinaryConditionalOperator.
>> MapTy OpaqueValues;
>>
>> Added: cfe/trunk/test/SemaCXX/constexpr-many-arguments.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constexpr-many-arguments.cpp?rev=159161&view=auto
>>
>> ==============================================================================
>> --- cfe/trunk/test/SemaCXX/constexpr-many-arguments.cpp (added)
>> +++ cfe/trunk/test/SemaCXX/constexpr-many-arguments.cpp Mon Jun 25
>> 16:21:08 2012
>> @@ -0,0 +1,42 @@
>> +// RUN: %clang_cc1 -std=c++11 -fsyntax-only %s
>> +// PR13197
>> +
>> +struct type1
>> +{
>> + constexpr type1(int a0) : my_data{a0} {}
>> + int my_data[1];
>> +};
>> +
>> +struct type2
>> +{
>> + typedef type1 T;
>> + constexpr type2(T a00, T a01, T a02, T a03, T a04, T a05, T a06, T
>> a07, T a08, T a09,
>> + T a10, T a11, T a12, T a13, T a14, T a15, T a16,
>> T a17, T a18, T a19,
>> + T a20, T a21, T a22)
>> + : my_data{a00, a01, a02, a03, a04, a05, a06, a07, a08, a09,
>> + a10, a11, a12, a13, a14, a15, a16, a17, a18, a19,
>> + a20, a21, a22}
>> + {}
>> + type1 my_data[23];
>> +};
>> +
>> +struct type3
>> +{
>> + constexpr type3(type2 a0, type2 a1) : my_data{a0, a1} {}
>> + type2 my_data[2];
>> +};
>> +
>> +constexpr type3 g
>> +{
>> + {
>> + {0},{0},{0},{0},{0},{0},{0},{0},{0},{0},
>> + {0},{0},{0},{0},{0},{0},{0},{0},{0},{0},
>> + {0},{0},{0}
>> + },
>> + {
>> + {0},{0},{0},{0},{0},{0},{0},{0},{0},{0},
>> + {0},{0},{0},{0},{0},{0},{0},{0},{0},{0},
>> + {0},{0},{0}
>> + }
>> +};
>> +
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120625/432ba5db/attachment.html>
More information about the cfe-commits
mailing list