Richard Smith | bb653bd | 2012-05-14 21:57:21 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -std=c++11 -S -emit-llvm -o - %s -triple x86_64-linux-gnu | FileCheck %s |
| 2 | |
| 3 | struct A { int a, b; int f(); }; |
| 4 | |
| 5 | // CHECK: define {{.*}}@_Z3fn1i( |
| 6 | int fn1(int x) { |
| 7 | // CHECK: %[[INITLIST:.*]] = alloca %struct.A |
David Blaikie | 218b783 | 2015-02-27 19:18:17 +0000 | [diff] [blame] | 8 | // CHECK: %[[A:.*]] = getelementptr inbounds %struct.A, %struct.A* %[[INITLIST]], i32 0, i32 0 |
Richard Smith | bb653bd | 2012-05-14 21:57:21 +0000 | [diff] [blame] | 9 | // CHECK: store i32 %{{.*}}, i32* %[[A]], align 4 |
David Blaikie | 218b783 | 2015-02-27 19:18:17 +0000 | [diff] [blame] | 10 | // CHECK: %[[B:.*]] = getelementptr inbounds %struct.A, %struct.A* %[[INITLIST]], i32 0, i32 1 |
Richard Smith | bb653bd | 2012-05-14 21:57:21 +0000 | [diff] [blame] | 11 | // CHECK: store i32 5, i32* %[[B]], align 4 |
| 12 | // CHECK: call i32 @_ZN1A1fEv(%struct.A* %[[INITLIST]]) |
| 13 | return A{x, 5}.f(); |
| 14 | } |
| 15 | |
| 16 | struct B { int &r; int &f() { return r; } }; |
| 17 | |
| 18 | // CHECK: define {{.*}}@_Z3fn2Ri( |
| 19 | int &fn2(int &v) { |
| 20 | // CHECK: %[[INITLIST2:.*]] = alloca %struct.B, align 8 |
David Blaikie | 218b783 | 2015-02-27 19:18:17 +0000 | [diff] [blame] | 21 | // CHECK: %[[R:.*]] = getelementptr inbounds %struct.B, %struct.B* %[[INITLIST2:.*]], i32 0, i32 0 |
Richard Smith | bb653bd | 2012-05-14 21:57:21 +0000 | [diff] [blame] | 22 | // CHECK: store i32* %{{.*}}, i32** %[[R]], align 8 |
Hal Finkel | a2347ba | 2014-07-18 15:52:10 +0000 | [diff] [blame] | 23 | // CHECK: call dereferenceable({{[0-9]+}}) i32* @_ZN1B1fEv(%struct.B* %[[INITLIST2:.*]]) |
Richard Smith | bb653bd | 2012-05-14 21:57:21 +0000 | [diff] [blame] | 24 | return B{v}.f(); |
| 25 | } |
Richard Smith | 8edda96 | 2014-06-13 23:04:49 +0000 | [diff] [blame] | 26 | |
| 27 | // CHECK: define {{.*}}@__cxx_global_var_init( |
| 28 | // |
| 29 | // CHECK: call {{.*}}@_ZN14NonTrivialInit1AC1Ev( |
| 30 | // CHECK: getelementptr inbounds {{.*}}, i64 1 |
| 31 | // CHECK: br i1 |
| 32 | // |
| 33 | // CHECK: getelementptr inbounds {{.*}}, i64 1 |
| 34 | // CHECK: icmp eq {{.*}}, i64 30 |
| 35 | // CHECK: br i1 |
| 36 | // |
| 37 | // CHECK: call i32 @__cxa_atexit( |
| 38 | namespace NonTrivialInit { |
| 39 | struct A { A(); A(const A&) = delete; ~A(); }; |
| 40 | struct B { A a[20]; }; |
| 41 | // NB, this must be large enough to be worth memsetting for this test to be |
| 42 | // meaningful. |
| 43 | B b[30] = {}; |
| 44 | } |