Skip to content

Commit

Permalink
[ASan] AddressSanitizerPass constructor should honor the AsanCtorKind…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
usama54321 committed Nov 17, 2023
1 parent c11be31 commit 4fe29d0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 4fe29d0

Please sign in to comment.