Skip to content

Commit 5386b8c

Browse files
committed
[ASan] AddressSanitizerPass constructor should honor the AsanCtorKind argument (llvm#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
1 parent a4b2a1f commit 5386b8c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,9 @@ class ModuleAddressSanitizer {
798798
// do globals-gc.
799799
UseCtorComdat(UseGlobalsGC && ClWithComdat && !this->CompileKernel),
800800
DestructorKind(DestructorKind),
801-
ConstructorKind(ConstructorKind) {
801+
ConstructorKind(ClConstructorKind.getNumOccurrences() > 0
802+
? ClConstructorKind
803+
: ConstructorKind) {
802804
C = &(M.getContext());
803805
int LongSize = M.getDataLayout().getPointerSizeInBits();
804806
IntptrTy = Type::getIntNTy(*C, LongSize);
@@ -1144,7 +1146,7 @@ AddressSanitizerPass::AddressSanitizerPass(
11441146
AsanCtorKind ConstructorKind)
11451147
: Options(Options), UseGlobalGC(UseGlobalGC),
11461148
UseOdrIndicator(UseOdrIndicator), DestructorKind(DestructorKind),
1147-
ConstructorKind(ClConstructorKind) {}
1149+
ConstructorKind(ConstructorKind) {}
11481150

11491151
PreservedAnalyses AddressSanitizerPass::run(Module &M,
11501152
ModuleAnalysisManager &MAM) {

0 commit comments

Comments
 (0)