Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / clang / test / AST / ByteCode / codegen.cpp
blobea2c812f30f6f0e28a35ef139b14e087c4066294
1 // RUN: %clang_cc1 -triple x86_64-linux -emit-llvm -o - %s | FileCheck %s
2 // RUN: %clang_cc1 -triple x86_64-linux -emit-llvm -o - %s -fexperimental-new-constant-interpreter | FileCheck %s
4 #ifdef __SIZEOF_INT128__
5 // CHECK: @PR11705 = global i128 0
6 __int128_t PR11705 = (__int128_t)&PR11705;
7 #endif
9 int arr[2];
10 // CHECK: @pastEnd = constant ptr getelementptr (i8, ptr @arr, i64 8)
11 int &pastEnd = arr[2];
13 // CHECK: @F = constant ptr @arr, align 8
14 int &F = arr[0];
16 struct S {
17 int a;
18 float c[3];
21 // CHECK: @s = global %struct.S zeroinitializer, align 4
22 S s;
23 // CHECK: @sp = constant ptr getelementptr (i8, ptr @s, i64 16), align 8
24 float &sp = s.c[3];
27 namespace BaseClassOffsets {
28 struct A { int a; };
29 struct B { int b; };
30 struct C : A, B { int c; };
32 extern C c;
33 // CHECK: @_ZN16BaseClassOffsets1aE = global ptr @_ZN16BaseClassOffsets1cE, align 8
34 A* a = &c;
35 // CHECK: @_ZN16BaseClassOffsets1bE = global ptr getelementptr (i8, ptr @_ZN16BaseClassOffsets1cE, i64 4), align 8
36 B* b = &c;
39 namespace ExprBase {
40 struct A { int n; };
41 struct B { int n; };
42 struct C : A, B {};
44 extern const int &&t = ((B&&)C{}).n;
45 // CHECK: @_ZGRN8ExprBase1tE_ = internal global {{.*}} zeroinitializer,
46 // CHECK: @_ZN8ExprBase1tE = constant ptr {{.*}} @_ZGRN8ExprBase1tE_, {{.*}} 8
49 namespace reinterpretcast {
50 const unsigned int n = 1234;
51 extern const int &s = reinterpret_cast<const int&>(n);
52 // CHECK: @_ZN15reinterpretcastL1nE = internal constant i32 1234, align 4
53 // CHECK: @_ZN15reinterpretcast1sE = constant ptr @_ZN15reinterpretcastL1nE, align 8
55 void *f1(unsigned long l) {
56 return reinterpret_cast<void *>(l);
58 // CHECK: define {{.*}} ptr @_ZN15reinterpretcast2f1Em
59 // CHECK: inttoptr
62 namespace Bitfield {
63 struct S { int a : 5; ~S(); };
64 // CHECK: alloca
65 // CHECK: call {{.*}}memset
66 // CHECK: store i32 {{.*}}, ptr @_ZGRN8Bitfield1rE_
67 // CHECK: call void @_ZN8Bitfield1SD1
68 // CHECK: store ptr @_ZGRN8Bitfield1rE_, ptr @_ZN8Bitfield1rE, align 8
69 int &&r = S().a;
72 namespace Null {
73 decltype(nullptr) null();
74 // CHECK: call {{.*}} @_ZN4Null4nullEv(
75 int *p = null();
76 struct S {};
77 // CHECK: call {{.*}} @_ZN4Null4nullEv(
78 int S::*q = null();
81 struct A {
82 A();
83 ~A();
84 enum E { Foo };
87 A *g();
89 void f(A *a) {
90 A::E e1 = a->Foo;
92 // CHECK: call noundef ptr @_Z1gv()
93 A::E e2 = g()->Foo;
94 // CHECK: call void @_ZN1AC1Ev(
95 // CHECK: call void @_ZN1AD1Ev(
96 A::E e3 = A().Foo;