[llvm] 4fe29d0 - [ASan] AddressSanitizerPass constructor should honor the AsanCtorKind argument (#72330)

via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 16 16:29:09 PST 2023


Author: Usama Hameed
Date: 2023-11-16T16:29:05-08:00
New Revision: 4fe29d0dc2f65e60ae7dde63e7f4595446f3baca

URL: https://github.com/llvm/llvm-project/commit/4fe29d0dc2f65e60ae7dde63e7f4595446f3baca
DIFF: https://github.com/llvm/llvm-project/commit/4fe29d0dc2f65e60ae7dde63e7f4595446f3baca.diff

LOG: [ASan] AddressSanitizerPass constructor should honor the AsanCtorKind argument (#72330)

Currently, the ConstructorKind member variable in AddressSanitizerPass
gets overriden by the ClConstructorKind whether the option is passed
from the command line or not. This override should only happen if the
ClConstructorKind argument is passed from the command line. Otherwise,
the constructor should honor the argument passed to it. This patch makes
this fix.

rdar://118423755

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
index 80c044b6bee8da2..c82b9260ee3419e 100644
--- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -803,7 +803,9 @@ class ModuleAddressSanitizer {
         // do globals-gc.
         UseCtorComdat(UseGlobalsGC && ClWithComdat && !this->CompileKernel),
         DestructorKind(DestructorKind),
-        ConstructorKind(ConstructorKind) {
+        ConstructorKind(ClConstructorKind.getNumOccurrences() > 0
+                            ? ClConstructorKind
+                            : ConstructorKind) {
     C = &(M.getContext());
     int LongSize = M.getDataLayout().getPointerSizeInBits();
     IntptrTy = Type::getIntNTy(*C, LongSize);
@@ -1151,7 +1153,7 @@ AddressSanitizerPass::AddressSanitizerPass(
     AsanCtorKind ConstructorKind)
     : Options(Options), UseGlobalGC(UseGlobalGC),
       UseOdrIndicator(UseOdrIndicator), DestructorKind(DestructorKind),
-      ConstructorKind(ClConstructorKind) {}
+      ConstructorKind(ConstructorKind) {}
 
 PreservedAnalyses AddressSanitizerPass::run(Module &M,
                                             ModuleAnalysisManager &MAM) {


        


More information about the llvm-commits mailing list