Skip to content

Commit dacfa24

Browse files
committed
Delete 'llvm.asan.globals' for global metadata.
Now that we have the sanitizer metadata that is actually on the global variable, and now that we use debuginfo in order to do symbolization of globals, we can delete the 'llvm.asan.globals' IR synthesis. This patch deletes the 'location' part of the __asan_global that's embedded in the binary as well, because it's unnecessary. This saves about ~1.7% of the optimised non-debug with-asserts clang binary. Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D127911
1 parent df18167 commit dacfa24

20 files changed

+84
-379
lines changed

clang/lib/CodeGen/BackendUtil.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,6 @@ static void addSanitizers(const Triple &TargetTriple,
676676
Opts.Recover = CodeGenOpts.SanitizeRecover.has(Mask);
677677
Opts.UseAfterScope = CodeGenOpts.SanitizeAddressUseAfterScope;
678678
Opts.UseAfterReturn = CodeGenOpts.getSanitizeAddressUseAfterReturn();
679-
MPM.addPass(RequireAnalysisPass<ASanGlobalsMetadataAnalysis, Module>());
680679
MPM.addPass(ModuleAddressSanitizerPass(
681680
Opts, UseGlobalGC, UseOdrIndicator, DestructorKind));
682681
}

clang/lib/CodeGen/SanitizerMetadata.cpp

-46
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ using namespace CodeGen;
2222

2323
SanitizerMetadata::SanitizerMetadata(CodeGenModule &CGM) : CGM(CGM) {}
2424

25-
// TODO(hctim): Can be removed when we migrate off of llvm.asan.globals. This
26-
// prevents llvm.asan.globals from being emitted for
27-
// __attribute__((disable_sanitizer_instrumentation)) and uses of
28-
// -fsanitize-ignorelist when a sanitizer isn't enabled.
2925
static bool isAsanHwasanOrMemTag(const SanitizerSet &SS) {
3026
return SS.hasOneOf(SanitizerKind::Address | SanitizerKind::KernelAddress |
3127
SanitizerKind::HWAddress | SanitizerKind::MemTag);
@@ -76,34 +72,7 @@ void SanitizerMetadata::reportGlobal(llvm::GlobalVariable *GV,
7672
Meta.IsDynInit = IsDynInit;
7773
}
7874

79-
bool IsExcluded = Meta.NoAddress || Meta.NoHWAddress || Meta.NoMemtag;
80-
8175
GV->setSanitizerMetadata(Meta);
82-
83-
// TODO(hctim): Code below can be removed when we migrate off of
84-
// llvm.asan.globals onto the new metadata attributes.
85-
llvm::Metadata *LocDescr = nullptr;
86-
llvm::Metadata *GlobalName = nullptr;
87-
llvm::LLVMContext &VMContext = CGM.getLLVMContext();
88-
if (!IsExcluded) {
89-
// Don't generate source location and global name if it is on
90-
// the NoSanitizeList - it won't be instrumented anyway.
91-
LocDescr = getLocationMetadata(Loc);
92-
if (!Name.empty())
93-
GlobalName = llvm::MDString::get(VMContext, Name);
94-
}
95-
96-
llvm::Metadata *GlobalMetadata[] = {
97-
llvm::ConstantAsMetadata::get(GV), LocDescr, GlobalName,
98-
llvm::ConstantAsMetadata::get(
99-
llvm::ConstantInt::get(llvm::Type::getInt1Ty(VMContext), IsDynInit)),
100-
llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(
101-
llvm::Type::getInt1Ty(VMContext), IsExcluded))};
102-
103-
llvm::MDNode *ThisGlobal = llvm::MDNode::get(VMContext, GlobalMetadata);
104-
llvm::NamedMDNode *AsanGlobals =
105-
CGM.getModule().getOrInsertNamedMetadata("llvm.asan.globals");
106-
AsanGlobals->addOperand(ThisGlobal);
10776
}
10877

10978
void SanitizerMetadata::reportGlobal(llvm::GlobalVariable *GV, const VarDecl &D,
@@ -137,18 +106,3 @@ void SanitizerMetadata::disableSanitizerForInstruction(llvm::Instruction *I) {
137106
I->setMetadata(llvm::LLVMContext::MD_nosanitize,
138107
llvm::MDNode::get(CGM.getLLVMContext(), None));
139108
}
140-
141-
llvm::MDNode *SanitizerMetadata::getLocationMetadata(SourceLocation Loc) {
142-
PresumedLoc PLoc = CGM.getContext().getSourceManager().getPresumedLoc(Loc);
143-
if (!PLoc.isValid())
144-
return nullptr;
145-
llvm::LLVMContext &VMContext = CGM.getLLVMContext();
146-
llvm::Metadata *LocMetadata[] = {
147-
llvm::MDString::get(VMContext, PLoc.getFilename()),
148-
llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(
149-
llvm::Type::getInt32Ty(VMContext), PLoc.getLine())),
150-
llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(
151-
llvm::Type::getInt32Ty(VMContext), PLoc.getColumn())),
152-
};
153-
return llvm::MDNode::get(VMContext, LocMetadata);
154-
}

clang/lib/CodeGen/SanitizerMetadata.h

-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ class SanitizerMetadata {
4646
bool IsDynInit = false);
4747
void disableSanitizerForGlobal(llvm::GlobalVariable *GV);
4848
void disableSanitizerForInstruction(llvm::Instruction *I);
49-
50-
llvm::MDNode *getLocationMetadata(SourceLocation Loc);
5149
};
5250
} // end namespace CodeGen
5351
} // end namespace clang

clang/test/CodeGen/asan-globals.cpp

+37-39
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: echo "int extra_global;" > %t.extra-source.cpp
22
// RUN: echo "global:*ignorelisted_global*" > %t.ignorelist
3-
// RUN: %clang_cc1 -include %t.extra-source.cpp -fsanitize=address -fsanitize-ignorelist=%t.ignorelist -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,ASAN
4-
// RUN: %clang_cc1 -include %t.extra-source.cpp -fsanitize=kernel-address -fsanitize-ignorelist=%t.ignorelist -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,KASAN
3+
// RUN: %clang_cc1 -include %t.extra-source.cpp -fsanitize=address -fsanitize-ignorelist=%t.ignorelist -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,GLOBS,ASAN
4+
// RUN: %clang_cc1 -include %t.extra-source.cpp -fsanitize=kernel-address -fsanitize-ignorelist=%t.ignorelist -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,GLOBS,KASAN
55
// The ignorelist file uses regexps, so Windows path backslashes.
66
// RUN: echo "src:%s" | sed -e 's/\\/\\\\/g' > %t.ignorelist-src
77
// RUN: %clang_cc1 -include %t.extra-source.cpp -fsanitize=address -fsanitize-ignorelist=%t.ignorelist-src -emit-llvm -o - %s | FileCheck %s --check-prefix=IGNORELIST-SRC
@@ -23,13 +23,31 @@ void func() {
2323
const char *literal = "Hello, world!";
2424
}
2525

26-
// ASAN: @{{.*}}dyn_init_global{{.*}} ={{.*}} global {{.*}}, sanitize_address_dyninit
27-
// KASAN: @{{.*}}dyn_init_global{{.*}} ={{.*}} global {{.*}}, sanitize_address_dyninit
26+
// GLOBS: @{{.*}}extra_global{{.*}} ={{.*}} global
27+
// GLOBS-NOT: no_sanitize_address
28+
// GLOBS: @{{.*}}global{{.*}} ={{.*}} global
29+
// GLOBS-NOT: no_sanitize_address
30+
// GLOBS: @{{.*}}dyn_init_global{{.*}} ={{.*}} global {{.*}}, sanitize_address_dyninit
31+
// GLOBS-NOT: no_sanitize_address
2832

29-
// ASAN: sectioned_global{{.*}} global { i32, [28 x i8] }{{.*}}, align 32
30-
// KASAN: sectioned_global{{.*}} global i32
31-
// ASAN: @__special_global{{.*}} global { i32, [28 x i8] }{{.*}}, align 32
32-
// KASAN: @__special_global{{.*}} global i32
33+
// GLOBS: @attributed_global = global {{.*}} no_sanitize_address
34+
// GLOBS: @disable_instrumentation_global = global {{.*}} no_sanitize_address
35+
// GLOBS: @ignorelisted_global = global {{.*}} no_sanitize_address
36+
37+
// ASAN: sectioned_global{{.*}} global { i32, [28 x i8] }{{.*}}, align 32
38+
// ASAN-NOT: no_sanitize_address
39+
// ASAN: @__special_global{{.*}} global { i32, [28 x i8] }{{.*}}, align 32
40+
// ASAN-NOT: no_sanitize_address
41+
42+
/// Note: No attribute is added by the IR pass, but the type didn't change, so
43+
/// that checks our assertions that the globals didn't get instrumented.
44+
// KASAN: sectioned_global{{.*}} global i32 {{.*}}
45+
// KASAN: @__special_global{{.*}} global i32 {{.*}}
46+
47+
// GLOBS: @{{[^ ]*}}static_var{{[^ ]*}} = internal global {{.*}}
48+
// GLOBS-NOT: no_sanitize_address
49+
// GLOBS: @{{.*}} = internal constant {{.*}}"Hello, world!{{.*}}
50+
// GLOBS-NOT: no_sanitize_address
3351

3452
/// Without -fasynchronous-unwind-tables, ctor and dtor get the uwtable attribute.
3553
// CHECK-LABEL: define internal void @asan.module_ctor() #[[#ATTR:]] {
@@ -54,34 +72,14 @@ void func() {
5472
// UWTABLE: attributes #[[#ATTR]] = { nounwind uwtable }
5573
// UWTABLE: ![[#]] = !{i32 7, !"uwtable", i32 2}
5674

57-
// CHECK: !llvm.asan.globals = !{![[EXTRA_GLOBAL:[0-9]+]], ![[GLOBAL:[0-9]+]], ![[DYN_INIT_GLOBAL:[0-9]+]], ![[ATTR_GLOBAL:[0-9]+]], ![[DISABLE_INSTR_GLOBAL:[0-9]+]], ![[IGNORELISTED_GLOBAL:[0-9]+]], ![[SECTIONED_GLOBAL:[0-9]+]], ![[SPECIAL_GLOBAL:[0-9]+]], ![[STATIC_VAR:[0-9]+]], ![[LITERAL:[0-9]+]]}
58-
// CHECK: ![[EXTRA_GLOBAL]] = !{{{.*}} ![[EXTRA_GLOBAL_LOC:[0-9]+]], !"extra_global", i1 false, i1 false}
59-
// CHECK: ![[EXTRA_GLOBAL_LOC]] = !{!"{{.*}}extra-source.cpp", i32 1, i32 5}
60-
// CHECK: ![[GLOBAL]] = !{{{.*}} ![[GLOBAL_LOC:[0-9]+]], !"global", i1 false, i1 false}
61-
// CHECK: ![[GLOBAL_LOC]] = !{!"{{.*}}asan-globals.cpp", i32 10, i32 5}
62-
// CHECK: ![[DYN_INIT_GLOBAL]] = !{{{.*}} ![[DYN_INIT_LOC:[0-9]+]], !"dyn_init_global", i1 true, i1 false}
63-
// CHECK: ![[DYN_INIT_LOC]] = !{!"{{.*}}asan-globals.cpp", i32 11, i32 5}
64-
// CHECK: ![[ATTR_GLOBAL]] = !{{{.*attributed_global.*}}, null, null, i1 false, i1 true}
65-
// CHECK: ![[DISABLE_INSTR_GLOBAL]] = !{{{.*disable_instrumentation_global.*}}, null, null, i1 false, i1 true}
66-
// CHECK: ![[IGNORELISTED_GLOBAL]] = !{{{.*ignorelisted_global.*}}, null, null, i1 false, i1 true}
67-
// CHECK: ![[SECTIONED_GLOBAL]] = !{{{.*}} ![[SECTIONED_GLOBAL_LOC:[0-9]+]], !"sectioned_global", i1 false, i1 false}
68-
// CHECK: ![[SECTIONED_GLOBAL_LOC]] = !{!"{{.*}}asan-globals.cpp", i32 16, i32 50}
69-
// CHECK: ![[SPECIAL_GLOBAL]] = !{{{.*}} ![[SPECIAL_GLOBAL_LOC:[0-9]+]], !"__special_global", i1 false, i1 false}
70-
// CHECK: ![[SPECIAL_GLOBAL_LOC]] = !{!"{{.*}}asan-globals.cpp", i32 18, i32 5}
71-
// CHECK: ![[STATIC_VAR]] = !{{{.*}} ![[STATIC_LOC:[0-9]+]], !"static_var", i1 false, i1 false}
72-
// CHECK: ![[STATIC_LOC]] = !{!"{{.*}}asan-globals.cpp", i32 22, i32 14}
73-
// CHECK: ![[LITERAL]] = !{{{.*}} ![[LITERAL_LOC:[0-9]+]], !"<string literal>", i1 false, i1 false}
74-
// CHECK: ![[LITERAL_LOC]] = !{!"{{.*}}asan-globals.cpp", i32 23, i32 25}
75-
76-
// IGNORELIST-SRC: !llvm.asan.globals = !{![[EXTRA_GLOBAL:[0-9]+]], ![[GLOBAL:[0-9]+]], ![[DYN_INIT_GLOBAL:[0-9]+]], ![[ATTR_GLOBAL:[0-9]+]], ![[DISABLE_INSTR_GLOBAL:[0-9]+]], ![[IGNORELISTED_GLOBAL:[0-9]+]], ![[SECTIONED_GLOBAL:[0-9]+]], ![[SPECIAL_GLOBAL:[0-9]+]], ![[STATIC_VAR:[0-9]+]], ![[LITERAL:[0-9]+]]}
77-
// IGNORELIST-SRC: ![[EXTRA_GLOBAL]] = !{{{.*}} ![[EXTRA_GLOBAL_LOC:[0-9]+]], !"extra_global", i1 false, i1 false}
78-
// IGNORELIST-SRC: ![[EXTRA_GLOBAL_LOC]] = !{!"{{.*}}extra-source.cpp", i32 1, i32 5}
79-
// IGNORELIST-SRC: ![[GLOBAL]] = !{{{.*}} null, null, i1 false, i1 true}
80-
// IGNORELIST-SRC: ![[DYN_INIT_GLOBAL]] = !{{{.*}} null, null, i1 true, i1 true}
81-
// IGNORELIST-SRC: ![[ATTR_GLOBAL]] = !{{{.*attributed_global.*}}, null, null, i1 false, i1 true}
82-
// IGNORELIST-SRC: ![[DISABLE_INSTR_GLOBAL]] = !{{{.*disable_instrumentation_global.*}}, null, null, i1 false, i1 true}
83-
// IGNORELIST-SRC: ![[IGNORELISTED_GLOBAL]] = !{{{.*ignorelisted_global.*}}, null, null, i1 false, i1 true}
84-
// IGNORELIST-SRC: ![[SECTIONED_GLOBAL]] = !{{{.*}} null, null, i1 false, i1 true}
85-
// IGNORELIST-SRC: ![[SPECIAL_GLOBAL]] = !{{{.*}} null, null, i1 false, i1 true}
86-
// IGNORELIST-SRC: ![[STATIC_VAR]] = !{{{.*}} null, null, i1 false, i1 true}
87-
// IGNORELIST-SRC: ![[LITERAL]] = !{{{.*}} null, null, i1 false, i1 true}
75+
// IGNORELIST-SRC: @extra_global = global {{.*}}
76+
// IGNORELIST-SRC-NOT: no_sanitize_address
77+
// IGNORELIST-SRC: @global = global {{.*}} no_sanitize_address
78+
// IGNORELIST-SRC: @dyn_init_global = global {{.*}} no_sanitize_address
79+
// IGNORELIST-SRC: @attributed_global = global {{.*}} no_sanitize_address
80+
// IGNORELIST-SRC: @disable_instrumentation_global = global {{.*}} no_sanitize_address
81+
// IGNORELIST-SRC: @ignorelisted_global = global {{.*}} no_sanitize_address
82+
// IGNORELIST-SRC: @sectioned_global = global {{.*}} no_sanitize_address
83+
// IGNORELIST-SRC: @__special_global = global {{.*}} no_sanitize_address
84+
// IGNORELIST-SRC: @{{[^ ]*}}static_var{{[^ ]*}} = internal global {{.*}} no_sanitize_address
85+
// IGNORELIST-SRC: @.str = {{.*}} constant {{.*}}"Hello, world!{{.*}} no_sanitize_address

clang/test/CodeGen/hwasan-globals.cpp

+1-24
Original file line numberDiff line numberDiff line change
@@ -28,33 +28,10 @@ void func() {
2828
// CHECK: @{{.*}}static_var{{.*}}.hwasan{{.*}} =
2929
// CHECK: @{{.*}}.hwasan{{.*}} = {{.*}} c"Hello, world!\00"
3030

31-
// CHECK: !llvm.asan.globals = !{![[EXTRA_GLOBAL:[0-9]+]], ![[GLOBAL:[0-9]+]], ![[ATTR_GLOBAL:[0-9]+]], ![[DISABLE_INSTR_GLOBAL:[0-9]+]], ![[IGNORELISTED_GLOBAL:[0-9]+]], ![[STATIC_VAR:[0-9]+]], ![[LITERAL:[0-9]+]]}
32-
// CHECK: ![[EXTRA_GLOBAL]] = !{{{.*}} ![[EXTRA_GLOBAL_LOC:[0-9]+]], !"extra_global", i1 false, i1 false}
33-
// CHECK: ![[EXTRA_GLOBAL_LOC]] = !{!"{{.*}}extra-source.cpp", i32 1, i32 5}
34-
// CHECK: ![[GLOBAL]] = !{{{.*}} ![[GLOBAL_LOC:[0-9]+]], !"global", i1 false, i1 false}
35-
// CHECK: ![[GLOBAL_LOC]] = !{!"{{.*}}hwasan-globals.cpp", i32 13, i32 5}
36-
// CHECK: ![[ATTR_GLOBAL]] = !{{{.*attributed_global.*}}, null, null, i1 false, i1 true}
37-
// CHECK: ![[DISABLE_INSTR_GLOBAL]] = !{{{.*disable_instrumentation_global.*}}, null, null, i1 false, i1 true}
38-
// CHECK: ![[IGNORELISTED_GLOBAL]] = !{{{.*ignorelisted_global.*}}, null, null, i1 false, i1 true}
39-
// CHECK: ![[STATIC_VAR]] = !{{{.*}} ![[STATIC_LOC:[0-9]+]], !"static_var", i1 false, i1 false}
40-
// CHECK: ![[STATIC_LOC]] = !{!"{{.*}}hwasan-globals.cpp", i32 19, i32 14}
41-
// CHECK: ![[LITERAL]] = !{{{.*}} ![[LITERAL_LOC:[0-9]+]], !"<string literal>", i1 false, i1 false}
42-
// CHECK: ![[LITERAL_LOC]] = !{!"{{.*}}hwasan-globals.cpp", i32 20, i32 25}
43-
4431
// IGNORELIST: @{{.*}}global{{.*}} ={{.*}} global {{.*}}, no_sanitize_hwaddress
4532
// IGNORELIST: @{{.*}}attributed_global{{.*}} ={{.*}} global {{.*}}, no_sanitize_hwaddress
4633
// IGNORELIST: @{{.*}}disable_instrumentation_global{{.*}} ={{.*}} global {{.*}}, no_sanitize_hwaddress
4734
// IGNORELIST: @{{.*}}ignorelisted_globa{{.*}} ={{.*}} global {{.*}}, no_sanitize_hwaddress
4835
// IGNORELIST: @{{.*}}static_var{{.*}} ={{.*}} global {{.*}}, no_sanitize_hwaddress
4936
// IGNORELIST: @{{.*}} = {{.*}} c"Hello, world!\00"{{.*}}, no_sanitize_hwaddress
50-
// IGNORELIST: @{{.*}}extra_global{{.*}}.hwasan{{.*}} =
51-
52-
// IGNORELIST: !llvm.asan.globals = !{![[EXTRA_GLOBAL:[0-9]+]], ![[GLOBAL:[0-9]+]], ![[ATTR_GLOBAL:[0-9]+]], ![[DISABLE_INSTR_GLOBAL:[0-9]+]], ![[IGNORELISTED_GLOBAL:[0-9]+]], ![[STATIC_VAR:[0-9]+]], ![[LITERAL:[0-9]+]]}
53-
// IGNORELIST: ![[EXTRA_GLOBAL]] = !{{{.*}} ![[EXTRA_GLOBAL_LOC:[0-9]+]], !"extra_global", i1 false, i1 false}
54-
// IGNORELIST: ![[EXTRA_GLOBAL_LOC]] = !{!"{{.*}}extra-source.cpp", i32 1, i32 5}
55-
// IGNORELIST: ![[GLOBAL]] = !{{{.*}} null, null, i1 false, i1 true}
56-
// IGNORELIST: ![[ATTR_GLOBAL]] = !{{{.*attributed_global.*}}, null, null, i1 false, i1 true}
57-
// IGNORELIST: ![[DISABLE_INSTR_GLOBAL]] = !{{{.*disable_instrumentation_global.*}}, null, null, i1 false, i1 true}
58-
// IGNORELIST: ![[IGNORELISTED_GLOBAL]] = !{{{.*ignorelisted_global.*}}, null, null, i1 false, i1 true}
59-
// IGNORELIST: ![[STATIC_VAR]] = !{{{.*}} null, null, i1 false, i1 true}
60-
// IGNORELIST: ![[LITERAL]] = !{{{.*}} null, null, i1 false, i1 true}
37+
// IGNORELIST: @extra_global.hwasan =

clang/test/CodeGen/memtag-globals.cpp

-23
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,6 @@ void func() {
2929
// CHECK: @{{.*}} = {{.*}} c"Hello, world!\00"
3030
// CHECK-NOT: no_sanitize_memtag
3131

32-
// CHECK: !llvm.asan.globals = !{![[EXTRA_GLOBAL:[0-9]+]], ![[GLOBAL:[0-9]+]], ![[ATTR_GLOBAL:[0-9]+]], ![[DISABLE_INSTR_GLOBAL:[0-9]+]], ![[IGNORELISTED_GLOBAL:[0-9]+]], ![[STATIC_VAR:[0-9]+]], ![[LITERAL:[0-9]+]]}
33-
// CHECK: ![[EXTRA_GLOBAL]] = !{{{.*}} ![[EXTRA_GLOBAL_LOC:[0-9]+]], !"extra_global", i1 false, i1 false}
34-
// CHECK: ![[EXTRA_GLOBAL_LOC]] = !{!"{{.*}}extra-source.cpp", i32 1, i32 5}
35-
// CHECK: ![[GLOBAL]] = !{{{.*}} ![[GLOBAL_LOC:[0-9]+]], !"global", i1 false, i1 false}
36-
// CHECK: ![[GLOBAL_LOC]] = !{!"{{.*}}memtag-globals.cpp", i32 10, i32 5}
37-
// CHECK: ![[ATTR_GLOBAL]] = !{{{.*attributed_global.*}}, null, null, i1 false, i1 true}
38-
// CHECK: ![[DISABLE_INSTR_GLOBAL]] = !{{{.*disable_instrumentation_global.*}}, null, null, i1 false, i1 true}
39-
// CHECK: ![[IGNORELISTED_GLOBAL]] = !{{{.*ignorelisted_global.*}}, null, null, i1 false, i1 true}
40-
// CHECK: ![[STATIC_VAR]] = !{{{.*}} ![[STATIC_LOC:[0-9]+]], !"static_var", i1 false, i1 false}
41-
// CHECK: ![[STATIC_LOC]] = !{!"{{.*}}memtag-globals.cpp", i32 16, i32 14}
42-
// CHECK: ![[LITERAL]] = !{{{.*}} ![[LITERAL_LOC:[0-9]+]], !"<string literal>", i1 false, i1 false}
43-
// CHECK: ![[LITERAL_LOC]] = !{!"{{.*}}memtag-globals.cpp", i32 17, i32 25}
44-
4532
// IGNORELIST: @{{.*}}extra_global{{.*}} ={{.*}} global
4633
// IGNORELIST-NOT: no_sanitize_memtag
4734
// IGNORELIST: @{{.*}}global{{.*}} ={{.*}} global {{.*}}, no_sanitize_memtag
@@ -50,13 +37,3 @@ void func() {
5037
// IGNORELIST: @{{.*}}ignorelisted_globa{{.*}} ={{.*}} global {{.*}}, no_sanitize_memtag
5138
// IGNORELIST: @{{.*}}static_var{{.*}} ={{.*}} global {{.*}}, no_sanitize_memtag
5239
// IGNORELIST: @{{.*}} = {{.*}} c"Hello, world!\00"{{.*}}, no_sanitize_memtag
53-
54-
// IGNORELIST: !llvm.asan.globals = !{![[EXTRA_GLOBAL:[0-9]+]], ![[GLOBAL:[0-9]+]], ![[ATTR_GLOBAL:[0-9]+]], ![[DISABLE_INSTR_GLOBAL:[0-9]+]], ![[IGNORELISTED_GLOBAL:[0-9]+]], ![[STATIC_VAR:[0-9]+]], ![[LITERAL:[0-9]+]]}
55-
// IGNORELIST: ![[EXTRA_GLOBAL]] = !{{{.*}} ![[EXTRA_GLOBAL_LOC:[0-9]+]], !"extra_global", i1 false, i1 false}
56-
// IGNORELIST: ![[EXTRA_GLOBAL_LOC]] = !{!"{{.*}}extra-source.cpp", i32 1, i32 5}
57-
// IGNORELIST: ![[GLOBAL]] = !{{{.*}} null, null, i1 false, i1 true}
58-
// IGNORELIST: ![[ATTR_GLOBAL]] = !{{{.*attributed_global.*}}, null, null, i1 false, i1 true}
59-
// IGNORELIST: ![[DISABLE_INSTR_GLOBAL]] = !{{{.*disable_instrumentation_global.*}}, null, null, i1 false, i1 true}
60-
// IGNORELIST: ![[IGNORELISTED_GLOBAL]] = !{{{.*ignorelisted_global.*}}, null, null, i1 false, i1 true}
61-
// IGNORELIST: ![[STATIC_VAR]] = !{{{.*}} null, null, i1 false, i1 true}
62-
// IGNORELIST: ![[LITERAL]] = !{{{.*}} null, null, i1 false, i1 true}

clang/test/CodeGen/sanitize-init-order.cpp

-12
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,6 @@ const volatile PODWithCtor array[5][5];
4444
// CHECK: @{{.*}}s3{{.*}} ={{.*}} global {{.*}}, sanitize_address_dyninit
4545
// CHECK: @{{.*}}array{{.*}} ={{.*}} global {{.*}}, sanitize_address_dyninit
4646

47-
// CHECK: !llvm.asan.globals = !{![[GLOB_1:[0-9]+]], ![[GLOB_2:[0-9]+]], ![[GLOB_3:[0-9]+]], ![[GLOB_4:[0-9]+]]
48-
// CHECK: ![[GLOB_1]] = !{%struct.PODStruct* {{.*}}, i1 false, i1 false}
49-
// CHECK: ![[GLOB_2]] = !{%struct.PODWithDtor* {{.*}}, i1 false, i1 false}
50-
// CHECK: ![[GLOB_3]] = !{%struct.PODWithCtorAndDtor* {{.*}}, i1 true, i1 false}
51-
// CHECK: ![[GLOB_4]] = !{{{.*}}class.NS::PODWithCtor{{.*}}, i1 true, i1 false}
52-
5347
// IGNORELIST: @{{.*}}s1{{.*}} ={{.*}} global
5448
// IGNORELIST-NOT: sanitize_address_dyninit
5549
// IGNORELIST: @{{.*}}s2{{.*}} ={{.*}} global
@@ -58,9 +52,3 @@ const volatile PODWithCtor array[5][5];
5852
// IGNORELIST-NOT: sanitize_address_dyninit
5953
// IGNORELIST: @{{.*}}array{{.*}} ={{.*}} global
6054
// IGNORELIST-NOT: sanitize_address_dyninit
61-
62-
// IGNORELIST: !llvm.asan.globals = !{![[GLOB_1:[0-9]+]], ![[GLOB_2:[0-9]+]], ![[GLOB_3:[0-9]+]], ![[GLOB_4:[0-9]+]]}
63-
// IGNORELIST: ![[GLOB_1]] = !{%struct.PODStruct* {{.*}}, i1 false, i1 false}
64-
// IGNORELIST: ![[GLOB_2]] = !{%struct.PODWithDtor* {{.*}}, i1 false, i1 false}
65-
// IGNORELIST: ![[GLOB_3]] = !{%struct.PODWithCtorAndDtor* {{.*}}, i1 false, i1 false}
66-
// IGNORELIST: ![[GLOB_4]] = !{{{.*}}class.NS::PODWithCtor{{.*}}, i1 false, i1 false}

compiler-rt/test/asan/TestCases/global-location-nodebug.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
// CHECK: AddressSanitizer: global-buffer-overflow
1515
// CLASS_STATIC-NO-G: 0x{{.*}} is located 4 bytes to the right of global variable 'C::array' defined in '{{.*}}global-location.cpp' {{.*}} of size 40
1616
// GLOB-NO-G: 0x{{.*}} is located 4 bytes to the right of global variable 'global' defined in '{{.*}}global-location.cpp' {{.*}} of size 40
17-
// FUNC_STATIC-NO-G: 0x{{.*}} is located 4 bytes to the right of global variable 'array' defined in '{{.*}}global-location.cpp' {{.*}} of size 40
17+
// FUNC_STATIC-NO-G: 0x{{.*}} is located 4 bytes to the right of global variable 'main::array' defined in '{{.*}}global-location.cpp' {{.*}} of size 40
1818
// LITERAL-NO-G: 0x{{.*}} is located 0 bytes to the right of global variable {{.*}} defined in '{{.*}}global-location.cpp' {{.*}} of size 11
1919
// CHECK: SUMMARY: AddressSanitizer: global-buffer-overflow

compiler-rt/test/asan/TestCases/global-location.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ int main(int argc, char **argv) {
3030
case 'c': return C::array[one * 11];
3131
case 'f':
3232
static int array[10];
33-
// FUNC_STATIC: 0x{{.*}} is located 4 bytes to the right of global variable 'array' defined in '{{.*}}global-location.cpp:[[@LINE-1]]' {{.*}} of size 40
33+
// FUNC_STATIC: 0x{{.*}} is located 4 bytes to the right of global variable 'main::array' defined in '{{.*}}global-location.cpp:[[@LINE-1]]' {{.*}} of size 40
3434
memset(array, 0, 10);
3535
return array[one * 11];
3636
case 'l':

0 commit comments

Comments
 (0)