1; Defaults
2; RUN: opt < %s -asan -asan-module -enable-new-pm=0 -S | FileCheck %s --check-prefixes=CHECK-NOALIAS,CHECK-NOINDICATOR
3; RUN: opt < %s -passes='asan-pipeline' -S | FileCheck %s --check-prefixes=CHECK-NOALIAS,CHECK-NOINDICATOR
4
5; {newPM,legacyPM} x {alias0,alias1} x {odr0,odr1}
6; RUN: opt < %s -asan -asan-module -enable-new-pm=0 -asan-use-private-alias=0 -asan-use-odr-indicator=0 -S | FileCheck %s --check-prefixes=CHECK-NOALIAS,CHECK-NOINDICATOR
7; RUN: opt < %s -passes='asan-pipeline'             -asan-use-private-alias=0 -asan-use-odr-indicator=0 -S | FileCheck %s --check-prefixes=CHECK-NOALIAS,CHECK-NOINDICATOR
8; RUN: opt < %s -asan -asan-module -enable-new-pm=0 -asan-use-private-alias=1 -asan-use-odr-indicator=0 -S | FileCheck %s --check-prefixes=CHECK-ALIAS,CHECK-NOINDICATOR
9; RUN: opt < %s -passes='asan-pipeline'             -asan-use-private-alias=1 -asan-use-odr-indicator=0 -S | FileCheck %s --check-prefixes=CHECK-ALIAS,CHECK-NOINDICATOR
10; RUN: opt < %s -asan -asan-module -enable-new-pm=0 -asan-use-private-alias=0 -asan-use-odr-indicator=1 -S | FileCheck %s --check-prefixes=CHECK-NOALIAS,CHECK-INDICATOR
11; RUN: opt < %s -passes='asan-pipeline'             -asan-use-private-alias=0 -asan-use-odr-indicator=1 -S | FileCheck %s --check-prefixes=CHECK-NOALIAS,CHECK-INDICATOR
12; RUN: opt < %s -asan -asan-module -enable-new-pm=0 -asan-use-private-alias=1 -asan-use-odr-indicator=1 -S | FileCheck %s --check-prefixes=CHECK-ALIAS,CHECK-INDICATOR
13; RUN: opt < %s -passes='asan-pipeline'             -asan-use-private-alias=1 -asan-use-odr-indicator=1 -S | FileCheck %s --check-prefixes=CHECK-ALIAS,CHECK-INDICATOR
14
15target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
16target triple = "x86_64-unknown-linux-gnu"
17
18@a = dso_local global [2 x i32] zeroinitializer, align 4
19@b = private global [2 x i32] zeroinitializer, align 4
20@c = internal global [2 x i32] zeroinitializer, align 4
21@d = unnamed_addr global [2 x i32] zeroinitializer, align 4
22
23; Check that we generate internal alias and odr indicator symbols for global to be protected.
24; CHECK-NOINDICATOR-NOT: __odr_asan_gen_a
25; CHECK-NOALIAS-NOT: private alias
26; CHECK-INDICATOR: @__odr_asan_gen_a = global i8 0, align 1
27; CHECK-ALIAS: @0 = private alias { [2 x i32], [56 x i8] }, { [2 x i32], [56 x i8] }* @a
28
29; CHECK-ALIAS: @1 = private alias { [2 x i32], [56 x i8] }, { [2 x i32], [56 x i8] }* @b
30; CHECK-ALIAS: @2 = private alias { [2 x i32], [56 x i8] }, { [2 x i32], [56 x i8] }* @c
31; CHECK-ALIAS: @3 = private alias { [2 x i32], [56 x i8] }, { [2 x i32], [56 x i8] }* @d
32
33; Function Attrs: nounwind sanitize_address uwtable
34define i32 @foo(i32 %M) #0 {
35entry:
36  %M.addr = alloca i32, align 4
37  store i32 %M, i32* %M.addr, align 4
38  store volatile i32 6, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @a, i64 2, i64 0), align 4
39  %0 = load i32, i32* %M.addr, align 4
40  %idxprom = sext i32 %0 to i64
41  %arrayidx = getelementptr inbounds [2 x i32], [2 x i32]* @a, i64 0, i64 %idxprom
42  %1 = load volatile i32, i32* %arrayidx, align 4
43  ret i32 %1
44}
45