Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGenCXX / no-odr-use.cpp
blob8c1e3415b9941c367ece81d416f7edf6b7dff9f4
1 // RUN: %clang_cc1 -std=c++11 -emit-llvm -o - -triple x86_64-linux-gnu %s | FileCheck %s --check-prefixes=CHECK,CHECK-CXX11
2 // RUN: %clang_cc1 -std=c++2a -emit-llvm -o - -triple x86_64-linux-gnu %s | FileCheck %s --check-prefixes=CHECK,CHECK-CXX2A
4 // CHECK-DAG: @__const._Z1fi.a = private unnamed_addr constant {{.*}} { i32 1, [2 x i32] [i32 2, i32 3], [3 x i32] [i32 4, i32 5, i32 6] }
5 // CHECK-CXX11-DAG: @_ZN7PR422765State1mE.const = private unnamed_addr constant [2 x { i64, i64 }] [{ {{.*}} @_ZN7PR422765State2f1Ev {{.*}}, i64 0 }, { {{.*}} @_ZN7PR422765State2f2Ev {{.*}}, i64 0 }]
6 // CHECK-CXX2A-DAG: @_ZN7PR422765State1mE = linkonce_odr constant [2 x { i64, i64 }] [{ {{.*}} @_ZN7PR422765State2f1Ev {{.*}}, i64 0 }, { {{.*}} @_ZN7PR422765State2f2Ev {{.*}}, i64 0 }], comdat
8 struct A { int x, y[2]; int arr[3]; };
9 // CHECK-LABEL: define{{.*}} i32 @_Z1fi(
10 int f(int i) {
11 // CHECK: call void {{.*}}memcpy{{.*}}({{.*}}, {{.*}} @__const._Z1fi.a
12 constexpr A a = {1, 2, 3, 4, 5, 6};
14 // CHECK-LABEL: define {{.*}}@"_ZZ1fiENK3$_0clEiM1Ai"(
15 return [] (int n, int A::*p) {
16 // CHECK: br i1
17 return (n >= 0
18 // CHECK: getelementptr inbounds [3 x i32], ptr getelementptr inbounds ({{.*}} @__const._Z1fi.a, i32 0, i32 2), i64 0, i64 %
19 ? a.arr[n]
20 // CHECK: br i1
21 : (n == -1
22 // CHECK: getelementptr inbounds i8, ptr @__const._Z1fi.a, i64 %
23 // CHECK: load i32
24 ? a.*p
25 // CHECK: getelementptr inbounds [2 x i32], ptr getelementptr inbounds ({{.*}} @__const._Z1fi.a, i32 0, i32 1), i64 0, i64 %
26 // CHECK: load i32
27 : a.y[2 - n]));
28 }(i, &A::x);
31 namespace PR42276 {
32 class State {
33 void syncDirtyObjects();
34 void f1(), f2();
35 using l = void (State::*)();
36 static constexpr l m[]{&State::f1, &State::f2};
38 // CHECK-LABEL: define{{.*}} void @_ZN7PR422765State16syncDirtyObjectsEv(
39 void State::syncDirtyObjects() {
40 for (int i = 0; i < sizeof(m) / sizeof(m[0]); ++i)
41 // CHECK-CXX11: getelementptr inbounds [2 x { i64, i64 }], ptr @_ZN7PR422765State1mE.const, i64 0, i64 %
42 // CHECK-CXX2A: getelementptr inbounds [2 x { i64, i64 }], ptr @_ZN7PR422765State1mE, i64 0, i64 %
43 (this->*m[i])();