[PATCH] D101362: [ASAN] NFC: Copy address space when creating globals with redzones

Reshabh Sharma via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 27 06:43:15 PDT 2021


rksharma created this revision.
rksharma added a reviewer: vitalybuka.
Herald added a subscriber: hiraditya.
rksharma requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Globals are copied and later replaced with equivalent globals with red zones. This patch makes sure that globals in supported address spaces will be replaced by globals with red zones in the same address space by copying the address space.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101362

Files:
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp


Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===================================================================
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -2358,9 +2358,9 @@
     GlobalValue::LinkageTypes Linkage = G->getLinkage();
     if (G->isConstant() && Linkage == GlobalValue::PrivateLinkage)
       Linkage = GlobalValue::InternalLinkage;
-    GlobalVariable *NewGlobal =
-        new GlobalVariable(M, NewTy, G->isConstant(), Linkage, NewInitializer,
-                           "", G, G->getThreadLocalMode());
+    GlobalVariable *NewGlobal = new GlobalVariable(
+        M, NewTy, G->isConstant(), Linkage, NewInitializer, "", G,
+        G->getThreadLocalMode(), G->getAddressSpace());
     NewGlobal->copyAttributesFrom(G);
     NewGlobal->setComdat(G->getComdat());
     NewGlobal->setAlignment(MaybeAlign(getMinRedzoneSizeForGlobal()));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101362.340818.patch
Type: text/x-patch
Size: 955 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210427/f93e6f01/attachment.bin>


More information about the llvm-commits mailing list