This revision was automatically updated to reflect the committed changes.
Closed by commit rG7045519359de: Add missing sanitizer metadata plumbing from 
CFE. (authored by hctim).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129492/new/

https://reviews.llvm.org/D129492

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/asan-globals.cpp
  clang/test/CodeGen/hwasan-globals.cpp
  clang/test/CodeGen/memtag-globals.cpp

Index: clang/test/CodeGen/memtag-globals.cpp
===================================================================
--- clang/test/CodeGen/memtag-globals.cpp
+++ clang/test/CodeGen/memtag-globals.cpp
@@ -11,10 +11,12 @@
 int __attribute__((no_sanitize("memtag"))) attributed_global;
 int __attribute__((disable_sanitizer_instrumentation)) disable_instrumentation_global;
 int ignorelisted_global;
+extern int external_global;
 
 void func() {
   static int static_var = 0;
   const char *literal = "Hello, world!";
+  external_global = 1;
 }
 
 // CHECK: @{{.*}}extra_global{{.*}} ={{.*}} sanitize_memtag
@@ -29,6 +31,7 @@
 
 // CHECK: @{{.*}}static_var{{.*}} ={{.*}} sanitize_memtag
 // CHECK: @{{.*}} = {{.*}} c"Hello, world!\00"{{.*}} sanitize_memtag
+// CHECK: @{{.*}}external_global{{.*}} ={{.*}} sanitize_memtag
 
 // IGNORELIST: @{{.*}}extra_global{{.*}} ={{.*}} sanitize_memtag
 
@@ -44,3 +47,5 @@
 // IGNORELIST-NOT: sanitize_memtag
 // IGNORELIST:     @{{.*}} = {{.*}} c"Hello, world!\00"{{.*}}
 // IGNORELIST-NOT: sanitize_memtag
+// IGNORELIST:     @{{.*}}external_global{{.*}} =
+// IGNORELIST-NOT: sanitize_memtag
Index: clang/test/CodeGen/hwasan-globals.cpp
===================================================================
--- clang/test/CodeGen/hwasan-globals.cpp
+++ clang/test/CodeGen/hwasan-globals.cpp
@@ -14,15 +14,18 @@
 int __attribute__((no_sanitize("hwaddress"))) attributed_global;
 int __attribute__((disable_sanitizer_instrumentation)) disable_instrumentation_global;
 int ignorelisted_global;
+extern int __attribute__((no_sanitize("hwaddress"))) external_global;
 
 void func() {
   static int static_var = 0;
   const char *literal = "Hello, world!";
+  external_global = 1;
 }
 
 // CHECK: @{{.*}}attributed_global{{.*}} ={{.*}} global {{.*}}, no_sanitize_hwaddress
 // CHECK: @{{.*}}disable_instrumentation_global{{.*}} ={{.*}} global {{.*}}, no_sanitize_hwaddress
 // CHECK: @{{.*}}ignorelisted_global{{.*}} ={{.*}} global {{.*}}, no_sanitize_hwaddress
+// CHECK: @{{.*}}external_global{{.*}} ={{.*}}, no_sanitize_hwaddress
 // CHECK: @{{.*}}extra_global{{.*}}.hwasan{{.*}} =
 // CHECK: @{{.*}}global{{.*}}.hwasan{{.*}} =
 // CHECK: @{{.*}}static_var{{.*}}.hwasan{{.*}} =
@@ -34,4 +37,5 @@
 // IGNORELIST: @{{.*}}ignorelisted_globa{{.*}} ={{.*}} global {{.*}}, no_sanitize_hwaddress
 // IGNORELIST: @{{.*}}static_var{{.*}} ={{.*}} global {{.*}}, no_sanitize_hwaddress
 // IGNORELIST: @{{.*}} = {{.*}} c"Hello, world!\00"{{.*}}, no_sanitize_hwaddress
+// IGNORELIST: @{{.*}}external_global{{.*}} ={{.*}}, no_sanitize_hwaddress
 // IGNORELIST: @{{.*}}extra_global{{.*}}.hwasan{{.*}} =
Index: clang/test/CodeGen/asan-globals.cpp
===================================================================
--- clang/test/CodeGen/asan-globals.cpp
+++ clang/test/CodeGen/asan-globals.cpp
@@ -12,6 +12,7 @@
 int __attribute__((no_sanitize("address"))) attributed_global;
 int __attribute__((disable_sanitizer_instrumentation)) disable_instrumentation_global;
 int ignorelisted_global;
+extern int __attribute__((no_sanitize("address"))) external_global;
 
 int __attribute__((section("__DATA, __common"))) sectioned_global; // KASAN - ignore globals in a section
 extern "C" {
@@ -21,6 +22,7 @@
 void func() {
   static int static_var = 0;
   const char *literal = "Hello, world!";
+  external_global = 1;
 }
 
 // GLOBS:     @{{.*}}extra_global{{.*}} ={{.*}} global
@@ -49,6 +51,8 @@
 // GLOBS:     @{{.*}} = {{.*}}c"Hello, world!\00"
 // GLOBS-NOT: no_sanitize_address
 
+// GLOBS: @{{.*}}external_global{{.*}} ={{.*}} no_sanitize_address
+
 /// Without -fasynchronous-unwind-tables, ctor and dtor get the uwtable attribute.
 // CHECK-LABEL: define internal void @asan.module_ctor() #[[#ATTR:]] {
 // ASAN-NEXT: call void @__asan_init
@@ -83,3 +87,4 @@
 // IGNORELIST-SRC:     @{{.*}}__special_global{{.*}} ={{.*}} global {{.*}} no_sanitize_address
 // IGNORELIST-SRC:     @{{.*}}static_var{{.*}} ={{.*}} global {{.*}} no_sanitize_address
 // IGNORELIST-SRC:     @{{.*}} ={{.*}} c"Hello, world!\00"{{.*}} no_sanitize_address
+// IGNORELIST-SRC:     @{{.*}}external_global{{.*}} ={{.*}} no_sanitize_address
Index: clang/lib/CodeGen/CodeGenModule.cpp
===================================================================
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -4293,6 +4293,9 @@
       getCUDARuntime().handleVarRegistration(D, *GV);
   }
 
+  if (D)
+    SanitizerMD->reportGlobal(GV, *D);
+
   LangAS ExpectedAS =
       D ? D->getType().getAddressSpace()
         : (LangOpts.OpenCL ? LangAS::opencl_global : LangAS::Default);
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to