Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGen / attr-nomerge.cpp
blob2d015f6164550cd3c88d961b73015b484a331a87
1 // RUN: %clang_cc1 -S -emit-llvm %s -triple x86_64-unknown-linux-gnu -o - | FileCheck %s
3 class A {
4 public:
5 [[clang::nomerge]] A();
6 [[clang::nomerge]] virtual ~A();
7 [[clang::nomerge]] void f();
8 [[clang::nomerge]] virtual void g();
9 [[clang::nomerge]] static void f1();
12 class B : public A {
13 public:
14 void g() override;
17 bool bar();
18 [[clang::nomerge]] void f(bool, bool);
19 [[clang::nomerge]] void (*fptr)(void);
21 void foo(int i, A *ap, B *bp) {
22 [[clang::nomerge]] bar();
23 [[clang::nomerge]] (i = 4, bar());
24 [[clang::nomerge]] (void)(bar());
25 f(bar(), bar());
26 fptr();
27 [[clang::nomerge]] [] { bar(); bar(); }(); // nomerge only applies to the anonymous function call
28 [[clang::nomerge]] for (bar(); bar(); bar()) {}
29 [[clang::nomerge]] { asm("nop"); }
30 bar();
32 ap->g();
33 bp->g();
35 A a;
36 a.f();
37 a.g();
38 A::f1();
40 B b;
41 b.g();
43 A *newA = new B();
44 delete newA;
47 int g(int i);
49 void something() {
50 g(1);
53 [[clang::nomerge]] int g(int i);
55 void something_else() {
56 g(1);
59 int g(int i) { return i; }
61 void something_else_again() {
62 g(1);
65 // CHECK: call noundef zeroext i1 @_Z3barv() #[[ATTR0:[0-9]+]]
66 // CHECK: call noundef zeroext i1 @_Z3barv() #[[ATTR0]]
67 // CHECK: call noundef zeroext i1 @_Z3barv() #[[ATTR0]]
68 // CHECK: call noundef zeroext i1 @_Z3barv(){{$}}
69 // CHECK: call noundef zeroext i1 @_Z3barv(){{$}}
70 // CHECK: call void @_Z1fbb({{.*}}) #[[ATTR0]]
71 // CHECK: %[[FPTR:.*]] = load ptr, ptr @fptr
72 // CHECK-NEXT: call void %[[FPTR]]() #[[ATTR0]]
73 // CHECK: call void @"_ZZ3fooiP1AP1BENK3$_0clEv"{{.*}} #[[ATTR0]]
74 // CHECK: call noundef zeroext i1 @_Z3barv() #[[ATTR0]]
75 // CHECK-LABEL: for.cond:
76 // CHECK: call noundef zeroext i1 @_Z3barv() #[[ATTR0]]
77 // CHECK-LABEL: for.inc:
78 // CHECK: call noundef zeroext i1 @_Z3barv() #[[ATTR0]]
79 // CHECK: call void asm sideeffect "nop"{{.*}} #[[ATTR1:[0-9]+]]
80 // CHECK: call noundef zeroext i1 @_Z3barv(){{$}}
81 // CHECK: load ptr, ptr
82 // CHECK: load ptr, ptr
83 // CHECK: %[[AG:.*]] = load ptr, ptr
84 // CHECK-NEXT: call void %[[AG]](ptr {{.*}}) #[[ATTR0]]
85 // CHECK: load ptr, ptr
86 // CHECK: load ptr, ptr
87 // CHECK: %[[BG:.*]] = load ptr, ptr
88 // CHECK-NEXT: call void %[[BG]](ptr noundef{{.*}}
89 // CHECK: call void @_ZN1AC1Ev({{.*}}) #[[ATTR0]]
90 // CHECK: call void @_ZN1A1fEv({{.*}}) #[[ATTR0]]
91 // CHECK: call void @_ZN1A1gEv({{.*}}) #[[ATTR0]]
92 // CHECK: call void @_ZN1A2f1Ev() #[[ATTR0]]
93 // CHECK: call void @_ZN1BC1Ev({{.*}}){{$}}
94 // CHECK: call void @_ZN1B1gEv({{.*}}){{$}}
95 // CHECK: call void @_ZN1BC1Ev({{.*}}){{$}}
96 // CHECK: load ptr, ptr
97 // CHECK: load ptr, ptr
98 // CHECK: %[[AG:.*]] = load ptr, ptr
99 // CHECK-NEXT: call void %[[AG]](ptr {{.*}}) #[[ATTR1]]
100 // CHECK: call void @_ZN1AD1Ev(ptr {{.*}}) #[[ATTR1]]
102 // CHECK-DAG: attributes #[[ATTR0]] = {{{.*}}nomerge{{.*}}}
103 // CHECK-DAG: attributes #[[ATTR1]] = {{{.*}}nomerge{{.*}}}