summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenCXX/cxx0x-initializer-array.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2015-03-06 20:00:03 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2015-03-06 20:00:03 +0000
commit3d8aa5c77db1de8f5c913abdb63885cc4d9143c5 (patch)
tree033dee13a1df9d6fbdf7852bfabc93d4f14cd4af /clang/test/CodeGenCXX/cxx0x-initializer-array.cpp
parent898d11e86468564d796ec87457ca060320ff46a1 (diff)
downloadbcm5719-llvm-3d8aa5c77db1de8f5c913abdb63885cc4d9143c5.tar.gz
bcm5719-llvm-3d8aa5c77db1de8f5c913abdb63885cc4d9143c5.zip
CodeGen: Emit constant temporaries into read-only globals.
Instead of creating a copy on the stack just stash them in a private constant global. This saves both the copying overhead and the stack space, and gives the optimizer more room to constant fold. This tries to make array temporaries more similar to regular arrays, they can't use the same logic because a temporary has no VarDecl to be bound to so we roll our own version here. The original use case for this optimization was code like for (int i : {1, 2, 3, 4, 5, 6, 7, 8, 10}) foo(i); where without this patch (assuming that the loop is not unrolled) we would alloca an array on the stack, copy the 10 values over and iterate on that. With this patch we put the array in .text use it directly. Apart from that case this helps on virtually any passing of a constant std::initializer_list as a function argument. Differential Revision: http://reviews.llvm.org/D8034 llvm-svn: 231508
Diffstat (limited to 'clang/test/CodeGenCXX/cxx0x-initializer-array.cpp')
-rw-r--r--clang/test/CodeGenCXX/cxx0x-initializer-array.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/clang/test/CodeGenCXX/cxx0x-initializer-array.cpp b/clang/test/CodeGenCXX/cxx0x-initializer-array.cpp
index 49bc86fadc7..de10aee67f1 100644
--- a/clang/test/CodeGenCXX/cxx0x-initializer-array.cpp
+++ b/clang/test/CodeGenCXX/cxx0x-initializer-array.cpp
@@ -42,10 +42,11 @@ namespace ValueInitArrayOfMemPtr {
// CHECK: call void @llvm.memcpy.p0i8.p0i8.i32(i8* %{{.*}}, i8* bitcast ([3 x i32]* @[[THREE_NULL_MEMPTRS]] to i8*), i32 12, i32 4, i1 false)
}
- // CHECK-LABEL: define void @_ZN22ValueInitArrayOfMemPtr1gEv
- void g() {
+ // Test dynamic initialization.
+ // CHECK-LABEL: define void @_ZN22ValueInitArrayOfMemPtr1gEMNS_1SEi
+ void g(p ptr) {
// CHECK: store i32 -1,
- f(a{});
+ f(a{ptr});
}
}
OpenPOWER on IntegriCloud