[PATCH] D127911: Delete 'llvm.asan.globals' for global metadata.

Vitaly Buka via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 24 16:46:59 PDT 2022

vitalybuka accepted this revision.
vitalybuka added inline comments.
This revision is now accepted and ready to land.

Comment at: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp:1355-1356
   // at all, we assume it has dynamic initializer (in other TU).
-  //
-  // FIXME: Metadata should be attched directly to the global directly instead
-  // of being added to llvm.asan.globals.
-  return G->hasInitializer() && !GlobalsMD.get(G).IsDynInit;
+  if (G->hasSanitizerMetadata() && G->getSanitizerMetadata().IsDynInit)
+    return false;
hctim wrote:
> vitalybuka wrote:
> > I believe previous was like this.
> > if you want to change that lets do another patch. 
> refactored it slightly, it's clear to me now (and IMHO much clearer to reason about, i suck at flipping multiple conditions in my head) that it's the same code
Before: G->hasInitializer() && !GlobalsMD.get(G).IsDynInit;
Now:  G->hasInitializer() && !(G->hasSanitizerMetadata() && G->getSanitizerMetadata().IsDynInit)

Which is fine, because previously NoMD == !IsDynInit

So logic-wise this version is LGTM
equivalent one-liner is even cleaner:
return G->hasInitializer() && !(G->hasSanitizerMetadata() && G->getSanitizerMetadata().IsDynInit)

  rG LLVM Github Monorepo



More information about the cfe-commits mailing list