xref: /llvm-project/clang/test/CodeGen/nobuiltin.c (revision 61d418f97154805100dc19ff2ef1338e9de2f27d)
1 // REQUIRES: x86-registered-target
2 
3 // RUN: %clang_cc1 -triple x86_64-linux-gnu -O1 -S -o - %s | FileCheck -check-prefix=STRCPY -check-prefix=MEMSET %s
4 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fno-builtin -O1 -S -o - %s | FileCheck -check-prefix=NOSTRCPY -check-prefix=NOMEMSET %s
5 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fno-builtin-memset -O1 -S -o - %s | FileCheck -check-prefix=STRCPY -check-prefix=NOMEMSET %s
6 
PR13497(void)7 void PR13497(void) {
8   char content[2];
9   // make sure we don't optimize this call to strcpy()
10   // STRCPY-NOT: __strcpy_chk
11   // NOSTRCPY: __strcpy_chk
12   __builtin___strcpy_chk(content, "", 1);
13 }
14 
PR4941(char * s)15 void PR4941(char *s) {
16   // Make sure we don't optimize this loop to a memset().
17   // NOMEMSET-NOT: memset
18   // MEMSET: memset
19   for (unsigned i = 0; i < 8192; ++i)
20     s[i] = 0;
21 }
22