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

Mitch Phillips via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 24 16:33:19 PDT 2022

hctim added inline comments.

Comment at: clang/lib/CodeGen/SanitizerMetadata.cpp:67-72
+  if (FsanitizeArgument.has(SanitizerKind::Address) && !Meta.NoAddress) {
     IsDynInit &= !CGM.isInNoSanitizeList(SanitizerKind::Address |
                                          GV, Loc, Ty, "init");
     Meta.IsDynInit = IsDynInit;
vitalybuka wrote:
> I recommend to move this change into another patch
> and it should probably be:
> Meta.IsDynInit &= IsDynInit && FsanitizeArgument.has(SanitizerKind::Address) && !Meta.NoAddress && !CGM.isInNoSanitizeLis;
sure, will punt to follow-up patch (leaving comment open, will close it out when i've added the dependency)

Comment at: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp:34
 #include "llvm/BinaryFormat/MachO.h"
+#include "llvm/Demangle/Demangle.h"
 #include "llvm/IR/Argument.h"
vitalybuka wrote:
> Please don't demangle in this patch, or keep as close as possible to the current behaviour
> Also isn't demangling by compliler-rt is better? mangled form is shorter.
as discussed, current descriptor has the demangled name because it's provided by clang frontend in `llvm.asan.globals`.

to keep this migration as close to the original as possible, keeping demangle of names in descriptors here, but added a TODO for follow-up work to instead demangle in the runtime.

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;
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

  rG LLVM Github Monorepo



More information about the cfe-commits mailing list