summaryrefslogtreecommitdiff
path: root/test/CodeGen/nobuiltin.c
blob: 543918f67491b31a97f8cd1dc7a600620e1af242 (plain)
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
// REQUIRES: x86-registered-target

// RUN: %clang_cc1 -triple x86_64-linux-gnu -O1 -S -o - %s | FileCheck -check-prefix=STRCPY -check-prefix=MEMSET %s
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fno-builtin -O1 -S -o - %s | FileCheck -check-prefix=NOSTRCPY -check-prefix=NOMEMSET %s
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fno-builtin-memset -O1 -S -o - %s | FileCheck -check-prefix=STRCPY -check-prefix=NOMEMSET %s

// RUN: %clang_cc1 -triple x86_64-linux-gnu -O1 -fexperimental-new-pass-manager -S -o - %s | FileCheck -check-prefix=STRCPY -check-prefix=MEMSET %s
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fno-builtin -O1 -fexperimental-new-pass-manager -S -o - %s | FileCheck -check-prefix=NOSTRCPY -check-prefix=NOMEMSET %s
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fno-builtin-memset -O1 -fexperimental-new-pass-manager -S -o - %s | FileCheck -check-prefix=STRCPY -check-prefix=NOMEMSET %s

void PR13497() {
  char content[2];
  // make sure we don't optimize this call to strcpy()
  // STRCPY-NOT: __strcpy_chk
  // NOSTRCPY: __strcpy_chk
  __builtin___strcpy_chk(content, "", 1);
}

void PR4941(char *s) {
  // Make sure we don't optimize this loop to a memset().
  // NOMEMSET-NOT: memset
  // MEMSET: memset
  for (unsigned i = 0; i < 8192; ++i)
    s[i] = 0;
}