File: no-builtin.cpp

package info (click to toggle)
llvm-toolchain-16 1%3A16.0.6-15~deb11u2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,634,820 kB
  • sloc: cpp: 6,179,261; ansic: 1,216,205; asm: 741,319; python: 196,614; objc: 75,325; f90: 49,640; lisp: 32,396; pascal: 12,286; sh: 9,394; perl: 7,442; ml: 5,494; awk: 3,523; makefile: 2,723; javascript: 1,206; xml: 886; fortran: 581; cs: 573
file content (64 lines) | stat: -rw-r--r-- 2,933 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-linux-gnu -S -emit-llvm -o - %s | FileCheck %s

// CHECK-LABEL: define{{.*}} void @foo_no_mempcy() #0
extern "C" void foo_no_mempcy() __attribute__((no_builtin("memcpy"))) {}

// CHECK-LABEL: define{{.*}} void @foo_no_mempcy_twice() #0
extern "C" void foo_no_mempcy_twice() __attribute__((no_builtin("memcpy"))) __attribute__((no_builtin("memcpy"))) {}

// CHECK-LABEL: define{{.*}} void @foo_no_builtins() #1
extern "C" void foo_no_builtins() __attribute__((no_builtin)) {}

// CHECK-LABEL: define{{.*}} void @foo_no_mempcy_memset() #2
extern "C" void foo_no_mempcy_memset() __attribute__((no_builtin("memset", "memcpy"))) {}

// CHECK-LABEL: define{{.*}} void @separate_attrs() #2
extern "C" void separate_attrs() __attribute__((no_builtin("memset"))) __attribute__((no_builtin("memcpy"))) {}

// CHECK-LABEL: define{{.*}} void @separate_attrs_ordering() #2
extern "C" void separate_attrs_ordering() __attribute__((no_builtin("memcpy"))) __attribute__((no_builtin("memset"))) {}

struct A {
  virtual int foo() const __attribute__((no_builtin("memcpy"))) { return 1; }
  virtual ~A();
};

struct B : public A {
  int foo() const override __attribute__((no_builtin("memmove"))) { return 2; }
  virtual ~B();
};

// CHECK-LABEL: define{{.*}} void @call_a_foo(%struct.A* noundef %a) #3
extern "C" void call_a_foo(A *a) {
  // CHECK: %call = call noundef i32 %2(%struct.A* {{[^,]*}} %0)
  a->foo(); // virtual call is not annotated
}

// CHECK-LABEL: define{{.*}} void @call_b_foo(%struct.B* noundef %b) #3
extern "C" void call_b_foo(B *b) {
  // CHECK: %call = call noundef i32 %2(%struct.B* {{[^,]*}} %0)
  b->foo(); // virtual call is not annotated
}

// CHECK-LABEL: define{{.*}} void @call_foo_no_mempcy() #3
extern "C" void call_foo_no_mempcy() {
  // CHECK: call void @foo_no_mempcy() #7
  foo_no_mempcy(); // call gets annotated with "no-builtin-memcpy"
}

A::~A() {} // Anchoring A so A::foo() gets generated
B::~B() {} // Anchoring B so B::foo() gets generated

// CHECK-LABEL: define linkonce_odr noundef i32 @_ZNK1A3fooEv(%struct.A* noundef{{[^,]*}} %this) unnamed_addr #0 comdat align 2
// CHECK-LABEL: define linkonce_odr noundef i32 @_ZNK1B3fooEv(%struct.B* noundef{{[^,]*}} %this) unnamed_addr #6 comdat align 2

// CHECK:     attributes #0 = {{{.*}}"no-builtin-memcpy"{{.*}}}
// CHECK-NOT: attributes #0 = {{{.*}}"no-builtin-memmove"{{.*}}}
// CHECK-NOT: attributes #0 = {{{.*}}"no-builtin-memset"{{.*}}}
// CHECK:     attributes #1 = {{{.*}}"no-builtins"{{.*}}}
// CHECK:     attributes #2 = {{{.*}}"no-builtin-memcpy"{{.*}}"no-builtin-memset"{{.*}}}
// CHECK-NOT: attributes #2 = {{{.*}}"no-builtin-memmove"{{.*}}}
// CHECK:     attributes #6 = {{{.*}}"no-builtin-memmove"{{.*}}}
// CHECK-NOT: attributes #5 = {{{.*}}"no-builtin-memcpy"{{.*}}}
// CHECK-NOT: attributes #5 = {{{.*}}"no-builtin-memset"{{.*}}}
// CHECK:     attributes #7 = { "no-builtin-memcpy" }