Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / clang / test / CodeGen / no-builtin.cpp
blob54354bddc8b609e1e3d38bcc75c6b515115aac30
1 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s
3 // CHECK-LABEL: define{{.*}} void @foo_no_mempcy() #0
4 extern "C" void foo_no_mempcy() __attribute__((no_builtin("memcpy"))) {}
6 // CHECK-LABEL: define{{.*}} void @foo_no_mempcy_twice() #0
7 extern "C" void foo_no_mempcy_twice() __attribute__((no_builtin("memcpy"))) __attribute__((no_builtin("memcpy"))) {}
9 // CHECK-LABEL: define{{.*}} void @foo_no_builtins() #1
10 extern "C" void foo_no_builtins() __attribute__((no_builtin)) {}
12 // CHECK-LABEL: define{{.*}} void @foo_no_mempcy_memset() #2
13 extern "C" void foo_no_mempcy_memset() __attribute__((no_builtin("memset", "memcpy"))) {}
15 // CHECK-LABEL: define{{.*}} void @separate_attrs() #2
16 extern "C" void separate_attrs() __attribute__((no_builtin("memset"))) __attribute__((no_builtin("memcpy"))) {}
18 // CHECK-LABEL: define{{.*}} void @separate_attrs_ordering() #2
19 extern "C" void separate_attrs_ordering() __attribute__((no_builtin("memcpy"))) __attribute__((no_builtin("memset"))) {}
21 struct A {
22 virtual int foo() const __attribute__((no_builtin("memcpy"))) { return 1; }
23 virtual ~A();
26 struct B : public A {
27 int foo() const override __attribute__((no_builtin("memmove"))) { return 2; }
28 virtual ~B();
31 // CHECK-LABEL: define{{.*}} void @call_a_foo(ptr noundef %a) #3
32 extern "C" void call_a_foo(A *a) {
33 // CHECK: %call = call noundef i32 %1(ptr {{[^,]*}} %0)
34 a->foo(); // virtual call is not annotated
37 // CHECK-LABEL: define{{.*}} void @call_b_foo(ptr noundef %b) #3
38 extern "C" void call_b_foo(B *b) {
39 // CHECK: %call = call noundef i32 %1(ptr {{[^,]*}} %0)
40 b->foo(); // virtual call is not annotated
43 // CHECK-LABEL: define{{.*}} void @call_foo_no_mempcy() #3
44 extern "C" void call_foo_no_mempcy() {
45 // CHECK: call void @foo_no_mempcy() #6
46 foo_no_mempcy(); // call gets annotated with "no-builtin-memcpy"
49 A::~A() {} // Anchoring A so A::foo() gets generated
50 B::~B() {} // Anchoring B so B::foo() gets generated
52 // CHECK-LABEL: define linkonce_odr noundef i32 @_ZNK1A3fooEv(ptr noundef{{[^,]*}} %this) unnamed_addr #0 comdat align 2
53 // CHECK-LABEL: define linkonce_odr noundef i32 @_ZNK1B3fooEv(ptr noundef{{[^,]*}} %this) unnamed_addr #5 comdat align 2
55 // CHECK: attributes #0 = {{{.*}}"no-builtin-memcpy"{{.*}}}
56 // CHECK-NOT: attributes #0 = {{{.*}}"no-builtin-memmove"{{.*}}}
57 // CHECK-NOT: attributes #0 = {{{.*}}"no-builtin-memset"{{.*}}}
58 // CHECK: attributes #1 = {{{.*}}"no-builtins"{{.*}}}
59 // CHECK: attributes #2 = {{{.*}}"no-builtin-memcpy"{{.*}}"no-builtin-memset"{{.*}}}
60 // CHECK-NOT: attributes #2 = {{{.*}}"no-builtin-memmove"{{.*}}}
61 // CHECK: attributes #6 = {{{.*}}"no-builtin-memcpy"{{.*}}}
62 // CHECK-NOT: attributes #5 = {{{.*}}"no-builtin-memcpy"{{.*}}}
63 // CHECK-NOT: attributes #5 = {{{.*}}"no-builtin-memset"{{.*}}}
64 // CHECK: attributes #8 = { builtin nounwind }