[compiler-rt] [asan] Speed up ASan ODR indicator-based checking (PR #100923)

Artem Pianykh via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 30 15:01:42 PDT 2024


================
@@ -147,14 +163,21 @@ static void CheckODRViolationViaIndicator(const Global *g) {
     *odr_indicator = REGISTERED;
     return;
   }
+
+  // Fetch globals with the same ODR indicator.
+  auto *relevant_globals_lookup =
+      map_of_globals_by_indicator.find(g->odr_indicator);
+  if (!relevant_globals_lookup)
+    return;
+
+  ListOfGlobals *relevant_globals = relevant_globals_lookup->second;
   // If *odr_indicator is DEFINED, some module have already registered
   // externally visible symbol with the same name. This is an ODR violation.
-  for (ListOfGlobals *l = list_of_all_globals; l; l = l->next) {
-    if (g->odr_indicator == l->g->odr_indicator &&
-        (flags()->detect_odr_violation >= 2 || g->size != l->g->size) &&
+  for (ListOfGlobals *l = relevant_globals; l; l = l->next) {
+    if ((flags()->detect_odr_violation >= 2 || g->size != l->g->size) &&
----------------
artempyanykh wrote:

When `halt_on_error=1`, the first one's enough. If `halt_on_error=0`, my understanding is that keeping just the first one may make it report less violations. If keeping the existing behavior is not necessary, I can make it keep just the first global. We always halt on error, so for us just the first one would be enough. With that said, even when keeping the full list the perf was great compared to the current baseline.

LMK what you prefer. 

https://github.com/llvm/llvm-project/pull/100923


More information about the llvm-commits mailing list