[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / Driver / memtag_lto.c
blob2ad22141608c7c301cdc7f98a227007377835026
1 // REQUIRES: aarch64-registered-target
3 // No MTE, so no StackSafety.
5 // RUN: rm -f %t*
7 // -O1, no tagging
8 // RUN: %clang -O1 -target aarch64-unknown-linux -mllvm -stack-safety-print %s -S -o - 2>&1 | FileCheck %s
10 // Full LTO
11 // RUN: %clang -O1 -target aarch64-unknown-linux -c %s -Xclang -opaque-pointers -flto=full -o %t.ltonewpm1.bc
12 // RUN: %clang -O1 -target aarch64-unknown-linux -c -DBUILD2 %s -Xclang -opaque-pointers -flto=full -o %t.ltonewpm2.bc
13 // RUN: llvm-lto2 run -lto-opaque-pointers -o %t.ltonewpm %t.ltonewpm1.bc %t.ltonewpm2.bc -save-temps -stack-safety-print -thinlto-threads 1 -O1 \
14 // RUN: -r %t.ltonewpm1.bc,fn,plx \
15 // RUN: -r %t.ltonewpm1.bc,use,lx \
16 // RUN: -r %t.ltonewpm1.bc,use_local,plx \
17 // RUN: -r %t.ltonewpm1.bc,w, \
18 // RUN: -r %t.ltonewpm2.bc,use,plx \
19 // RUN: -r %t.ltonewpm2.bc,z, 2>&1 | FileCheck %s --allow-empty
21 // Thin LTO, new PM
22 // RUN: %clang -O1 -target aarch64-unknown-linux -c %s -Xclang -opaque-pointers -flto=thin -o %t.thinltonewpm1.bc
23 // RUN: %clang -O1 -target aarch64-unknown-linux -c -DBUILD2 %s -Xclang -opaque-pointers -flto=thin -o %t.thinltonewpm2.bc
24 // RUN: llvm-lto2 run -lto-opaque-pointers -o %t.thinltonewpm %t.thinltonewpm1.bc %t.thinltonewpm2.bc -save-temps -stack-safety-print -thinlto-threads 1 -O1 \
25 // RUN: -r %t.thinltonewpm1.bc,fn,plx \
26 // RUN: -r %t.thinltonewpm1.bc,use,lx \
27 // RUN: -r %t.thinltonewpm1.bc,use_local,plx \
28 // RUN: -r %t.thinltonewpm1.bc,w, \
29 // RUN: -r %t.thinltonewpm2.bc,use,plx \
30 // RUN: -r %t.thinltonewpm2.bc,z, 2>&1 | FileCheck %s --allow-empty
32 // Now with MTE.
33 // RUN: rm -f %t*
35 // -O0: both are unsafe.
36 // RUN: %clang -O0 -target aarch64-unknown-linux -march=armv8+memtag -fsanitize=memtag -mllvm -stack-safety-print %s -S -o - 2>&1 | FileCheck %s
38 // No LTO: just one is safe.
39 // RUN: %clang -O1 -target aarch64-unknown-linux -march=armv8+memtag -fsanitize=memtag -mllvm -stack-safety-print %s -S -o /dev/null 2>&1 | FileCheck %s -check-prefixes=SSI,XUNSAFE,YSAFE
41 // Full LTO: both are safe.
42 // RUN: %clang -O1 -target aarch64-unknown-linux -march=armv8+memtag -fsanitize=memtag -c %s -Xclang -opaque-pointers -flto=full -o %t.ltonewpm1.bc
43 // RUN: %clang -O1 -target aarch64-unknown-linux -march=armv8+memtag -fsanitize=memtag -c -DBUILD2 %s -Xclang -opaque-pointers -flto=full -o %t.ltonewpm2.bc
44 // RUN: llvm-lto2 run -lto-opaque-pointers -o %t.ltonewpm %t.ltonewpm1.bc %t.ltonewpm2.bc -save-temps -stack-safety-print -thinlto-threads 1 -O1 \
45 // RUN: -r %t.ltonewpm1.bc,fn,plx \
46 // RUN: -r %t.ltonewpm1.bc,use,lx \
47 // RUN: -r %t.ltonewpm1.bc,use_local,plx \
48 // RUN: -r %t.ltonewpm1.bc,w, \
49 // RUN: -r %t.ltonewpm2.bc,use,plx \
50 // RUN: -r %t.ltonewpm2.bc,z, 2>&1 | FileCheck %s -check-prefixes=SSI,XSAFE,YSAFE
52 // Thin LTO: both are safe.
53 // RUN: %clang -O1 -target aarch64-unknown-linux -march=armv8+memtag -fsanitize=memtag -c %s -Xclang -opaque-pointers -flto=thin -o %t.thinltonewpm1.bc
54 // RUN: %clang -O1 -target aarch64-unknown-linux -march=armv8+memtag -fsanitize=memtag -c -DBUILD2 %s -Xclang -opaque-pointers -flto=thin -o %t.thinltonewpm2.bc
55 // RUN: llvm-lto2 run -lto-opaque-pointers -o %t.thinltonewpm %t.thinltonewpm1.bc %t.thinltonewpm2.bc -save-temps -stack-safety-print -thinlto-threads 1 -O1 \
56 // RUN: -r %t.thinltonewpm1.bc,fn,plx \
57 // RUN: -r %t.thinltonewpm1.bc,use,lx \
58 // RUN: -r %t.thinltonewpm1.bc,use_local,plx \
59 // RUN: -r %t.thinltonewpm1.bc,w, \
60 // RUN: -r %t.thinltonewpm2.bc,use,plx \
61 // RUN: -r %t.thinltonewpm2.bc,z, 2>&1 | FileCheck %s -check-prefixes=SSI,XSAFE,YSAFE
63 void use(int *p);
65 #ifdef BUILD2
67 int z;
68 __attribute__((noinline)) void use(int *p) { *p = z; }
70 #else
72 char w;
73 __attribute__((noinline)) void use_local(char *p) { *p = w; }
75 // SSI-LABEL: @fn
76 // SSI-LABEL: allocas uses:
77 int fn() {
78 // XUNSAFE-DAG: [4]: full-set
79 // XSAFE-DAG: [4]: [0,4)
80 int x;
81 use(&x);
83 // YUNSAFE-DAG: [1]: full-set
84 // YSAFE-DAG: [1]: [0,1)
85 char y;
86 use_local(&y);
87 return x + y;
90 // CHECK-NOT: allocas uses:
92 #endif