diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-06-01 20:58:49 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-06-01 20:58:49 +0000 |
| commit | 416ada0f75bab22b084a1776deb229cd4a669c4d (patch) | |
| tree | 6eb65f3790434471361628af6199b07a4de92de7 /test/CodeGenCXX/stmtexpr.cpp | |
| parent | 550ae89a710bf458d47e5b1d183f5e7039c2b384 (diff) | |
Notes
Diffstat (limited to 'test/CodeGenCXX/stmtexpr.cpp')
| -rw-r--r-- | test/CodeGenCXX/stmtexpr.cpp | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/test/CodeGenCXX/stmtexpr.cpp b/test/CodeGenCXX/stmtexpr.cpp index 5885a1663e63..5bd9908d6c25 100644 --- a/test/CodeGenCXX/stmtexpr.cpp +++ b/test/CodeGenCXX/stmtexpr.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -Wno-unused-value -triple %itanium_abi_triple -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -Wno-unused-value -triple i686-linux-gnu -emit-llvm -o - %s | FileCheck %s // rdar: //8540501 extern "C" int printf(...); extern "C" void abort(); @@ -139,6 +139,34 @@ extern "C" int cleanup_exit_lvalue(bool cond) { // CHECK: %[[v:[^ ]*]] = load i32*, i32** %[[tmp]] // CHECK-NEXT: store i32* %[[v]], i32** %r +// Bind the reference to a byval argument. It is not an instruction or Constant, +// so it's a bit of a corner case. +struct ByVal { int x[3]; }; +extern "C" int cleanup_exit_lvalue_byval(bool cond, ByVal arg) { + ByVal &r = (A(1), ({ if (cond) return 0; (void)ByVal(); }), arg); + return r.x[0]; +} +// CHECK-LABEL: define{{.*}} i32 @cleanup_exit_lvalue_byval({{.*}}, %struct.ByVal* byval align 4 %arg) +// CHECK: call {{.*}} @_ZN1AC1Ei +// CHECK: call {{.*}} @_ZN1AD1Ev +// CHECK: switch +// CHECK: store %struct.ByVal* %arg, %struct.ByVal** %r + +// Bind the reference to a local variable. We don't need to spill it. Binding a +// reference to it doesn't generate any instructions. +extern "C" int cleanup_exit_lvalue_local(bool cond) { + int local = 42; + int &r = (A(1), ({ if (cond) return 0; (void)0; }), local); + return r; +} +// CHECK-LABEL: define{{.*}} i32 @cleanup_exit_lvalue_local({{.*}}) +// CHECK: %local = alloca i32 +// CHECK: store i32 42, i32* %local +// CHECK: call {{.*}} @_ZN1AC1Ei +// CHECK-NOT: store i32* %local +// CHECK: call {{.*}} @_ZN1AD1Ev +// CHECK: switch +// CHECK: store i32* %local, i32** %r, align 4 // We handle ExprWithCleanups for complex evaluation type separately, and it had // the same bug. |
