diff options
author | Leny Kholodov <lkholodov@accesssoftek.com> | 2015-06-08 10:23:49 +0000 |
---|---|---|
committer | Leny Kholodov <lkholodov@accesssoftek.com> | 2015-06-08 10:23:49 +0000 |
commit | 6aab1117e859b6cb0cc9a4753481a8ef563cf871 (patch) | |
tree | 3af9f3f6da73d56642fae02f356545bd862964ce /clang/test/CodeGenCXX/stack-reuse-miscompile.cpp | |
parent | c789e1d57bb9e4513dc212d1558e4c49bc88f8f5 (diff) | |
download | bcm5719-llvm-6aab1117e859b6cb0cc9a4753481a8ef563cf871.tar.gz bcm5719-llvm-6aab1117e859b6cb0cc9a4753481a8ef563cf871.zip |
[CodeGen] Reuse stack space from unused function results (with more accurate unused result detection)
This patch fixes issues with unused result detection which were found in patch http://reviews.llvm.org/D9743.
Differential Revision: http://reviews.llvm.org/D10042
llvm-svn: 239294
Diffstat (limited to 'clang/test/CodeGenCXX/stack-reuse-miscompile.cpp')
-rw-r--r-- | clang/test/CodeGenCXX/stack-reuse-miscompile.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/clang/test/CodeGenCXX/stack-reuse-miscompile.cpp b/clang/test/CodeGenCXX/stack-reuse-miscompile.cpp new file mode 100644 index 00000000000..e6b9cbe3365 --- /dev/null +++ b/clang/test/CodeGenCXX/stack-reuse-miscompile.cpp @@ -0,0 +1,39 @@ +// RUN: %clang -S -emit-llvm -O1 -mllvm -disable-llvm-optzns -S %s -o - | FileCheck %s + +// This test should not to generate llvm.lifetime.start/llvm.lifetime.end for +// f function because all temporary objects in this function are used for the +// final result + +class S { + char *ptr; + unsigned int len; +}; + +class T { + S left; + S right; + +public: + T(const char s[]); + T(S); + + T concat(const T &Suffix) const; + const char * str() const; +}; + +const char * f(S s) +{ +// CHECK: %1 = alloca %class.T, align 4 +// CHECK: %2 = alloca %class.T, align 4 +// CHECK: %3 = alloca %class.S, align 4 +// CHECK: %4 = alloca %class.T, align 4 +// CHECK: %5 = call x86_thiscallcc %class.T* @"\01??0T@@QAE@QBD@Z" +// CHECK: %6 = bitcast %class.S* %3 to i8* +// CHECK: %7 = bitcast %class.S* %s to i8* +// CHECK: call void @llvm.memcpy.p0i8.p0i8.i32 +// CHECK: %8 = call x86_thiscallcc %class.T* @"\01??0T@@QAE@VS@@@Z" +// CHECK: call x86_thiscallcc void @"\01?concat@T@@QBE?AV1@ABV1@@Z" +// CHECK: %9 = call x86_thiscallcc i8* @"\01?str@T@@QBEPBDXZ"(%class.T* %4) + + return T("[").concat(T(s)).str(); +} |