]> granicus.if.org Git - clang/commit
[CodeGen] Use the zero initializer instead of storing an all zero representation.
authorMatt Davis <Matthew.Davis@sony.com>
Fri, 9 Feb 2018 22:10:09 +0000 (22:10 +0000)
committerMatt Davis <Matthew.Davis@sony.com>
Fri, 9 Feb 2018 22:10:09 +0000 (22:10 +0000)
commit96146791456d66ac778b04138ec057ddfc5ce231
tree2659cb44ee2028310601d19858829b54957dc48d
parentf8d60284cbea7608b5aaf34f52062fbc03c8760f
[CodeGen] Use the zero initializer instead of storing an all zero representation.

Summary:
This change avoids the overhead of storing, and later crawling,
an initializer list of all zeros for arrays. When LLVM
visits this (llvm/IR/Constants.cpp) ConstantArray::getImpl()
it will scan the list looking for an array of all zero.

We can avoid the store, and short-cut the scan, by detecting
all zeros when clang builds-up the initialization representation.

This was brought to my attention when investigating PR36030

Reviewers: majnemer, rjmccall

Reviewed By: rjmccall

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D42549

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@324776 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/CGExprConstant.cpp
test/CodeGen/array-init.c [new file with mode: 0644]