rsmith added a comment.
I've done some more investigation, and I now think this patch is merely working
around deficiencies elsewhere. See https://reviews.llvm.org/D47166, which aims
to fix those deficiencies more directly.
Repository:
rC Clang
https://reviews.llvm.org/D46241
___
rsmith added inline comments.
Comment at: lib/CodeGen/CGExprConstant.cpp:1414-1415
+Expr::EvalResult Result;
+if (Init->EvaluateAsRValue(Result, CE.CGM.getContext()) &&
+!Result.hasUnacceptableSideEffect(Expr::SE_NoSideEffects))
+ return (Result.Val.isInt() &
This revision was automatically updated to reflect the committed changes.
Closed by commit rC332847: [CodeGen] Recognize more cases of zero
initialization (authored by sepavloff, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D46241?vs=146091&id=147798#toc
Repository:
rC C
sepavloff added a comment.
@rsmith Do yo think this patch is OK to apply?
Repository:
rC Clang
https://reviews.llvm.org/D46241
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
sepavloff added inline comments.
Comment at: lib/CodeGen/CGExprConstant.cpp:1414-1415
+Expr::EvalResult Result;
+if (Init->EvaluateAsRValue(Result, CE.CGM.getContext()) &&
+!Result.hasUnacceptableSideEffect(Expr::SE_NoSideEffects))
+ return (Result.Val.isInt(
rsmith added inline comments.
Comment at: lib/CodeGen/CGExprConstant.cpp:1414-1415
+Expr::EvalResult Result;
+if (Init->EvaluateAsRValue(Result, CE.CGM.getContext()) &&
+!Result.hasUnacceptableSideEffect(Expr::SE_NoSideEffects))
+ return (Result.Val.isInt() &
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.
Thanks, LGTM.
Repository:
rC Clang
https://reviews.llvm.org/D46241
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.ll
sepavloff updated this revision to Diff 146091.
sepavloff added a comment.
Updated patch
Try evaluating initializer value only if the initializer type is
integral or pointer. It avoids calculation of large value, which
then is discarded.
Repository:
rC Clang
https://reviews.llvm.org/D46241
rjmccall added inline comments.
Comment at: lib/CodeGen/CGExprConstant.cpp:1413
+ } else if (!Init->isEvaluatable(CE.CGM.getContext())) {
+return false;
+ } else if (InitTy->hasPointerRepresentation()) {
sepavloff wrote:
> rsmith wrote:
> > sepavloff wrote:
sepavloff added a comment.
> Hmm. In C++, a static object which isn't constant-initialized is
> zero-initialized, which is required to set any padding bits to zero (N4640
> [dcl.init]p6) in both structs and unions. In C, a static object which doesn't
> have an initializer also has all any paddi
sepavloff updated this revision to Diff 145735.
sepavloff added a comment.
Added treatment of structures/unions
Repository:
rC Clang
https://reviews.llvm.org/D46241
Files:
include/clang/AST/Expr.h
lib/AST/ExprConstant.cpp
lib/CodeGen/CGExprConstant.cpp
test/CodeGen/const-init.c
tes
rjmccall added inline comments.
Comment at: lib/CodeGen/CGExprConstant.cpp:1403
+ if (auto *IL = dyn_cast_or_null(Init)) {
+if (InitTy->isConstantArrayType()) {
+ for (auto I : IL->inits())
sepavloff wrote:
> rjmccall wrote:
> > Do you actually care if
sepavloff added inline comments.
Comment at: lib/CodeGen/CGExprConstant.cpp:1413
+ } else if (!Init->isEvaluatable(CE.CGM.getContext())) {
+return false;
+ } else if (InitTy->hasPointerRepresentation()) {
rsmith wrote:
> sepavloff wrote:
> > rjmccall wrote:
sepavloff updated this revision to Diff 145445.
sepavloff marked an inline comment as done.
sepavloff added a comment.
Avoid redundant initializer calculation
Repository:
rC Clang
https://reviews.llvm.org/D46241
Files:
include/clang/AST/Expr.h
lib/AST/ExprConstant.cpp
lib/CodeGen/CGExp
rsmith added inline comments.
Comment at: lib/CodeGen/CGExprConstant.cpp:1413
+ } else if (!Init->isEvaluatable(CE.CGM.getContext())) {
+return false;
+ } else if (InitTy->hasPointerRepresentation()) {
sepavloff wrote:
> rjmccall wrote:
> > Aren't the null-
sepavloff marked an inline comment as done.
sepavloff added inline comments.
Comment at: lib/CodeGen/CGExprConstant.cpp:1403
+ if (auto *IL = dyn_cast_or_null(Init)) {
+if (InitTy->isConstantArrayType()) {
+ for (auto I : IL->inits())
rjmccall wrote:
>
sepavloff updated this revision to Diff 145049.
sepavloff marked an inline comment as done.
sepavloff added a comment.
Small simplification
Repository:
rC Clang
https://reviews.llvm.org/D46241
Files:
lib/CodeGen/CGExprConstant.cpp
test/CodeGenCXX/cxx11-initializer-aggregate.cpp
Index:
rjmccall added inline comments.
Comment at: lib/CodeGen/CGExprConstant.cpp:1403
+ if (auto *IL = dyn_cast_or_null(Init)) {
+if (InitTy->isConstantArrayType()) {
+ for (auto I : IL->inits())
Do you actually care if it's an array initialization instead of
sepavloff marked 3 inline comments as done.
sepavloff added inline comments.
Comment at: lib/CodeGen/CGExprConstant.cpp:1414
+ return true;
+}
+ }
rjmccall wrote:
> You should check the array fill expression here; for now, the test case would
> be some
sepavloff updated this revision to Diff 144898.
sepavloff added a comment.
Addressed review notes.
Repository:
rC Clang
https://reviews.llvm.org/D46241
Files:
lib/CodeGen/CGExprConstant.cpp
test/CodeGenCXX/cxx11-initializer-aggregate.cpp
Index: test/CodeGenCXX/cxx11-initializer-aggrega
rjmccall added inline comments.
Comment at: lib/CodeGen/CGExprConstant.cpp:1395
+static bool isZeroInitializer(ConstantEmitter &CE, const Expr *Init) {
+ QualType InitTy = Init->getType().getCanonicalType();
You should have a comment here clarifying that this
sepavloff created this revision.
sepavloff added reviewers: rjmccall, rsmith.
If a variable has initializer, codegen tries to build its value. It
causes strange behavior from user viewpoint: compilation of huge zero
initialized arrays like:
int char data_1[2147483648u] = { 0 };
consumes enormo
22 matches
Mail list logo