Skip to content

Commit c04bfeb

Browse files
usama54321sr-tream
authored andcommitted
[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 91f0404 commit c04bfeb

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
@@ -803,7 +803,9 @@ class ModuleAddressSanitizer {
803803
// do globals-gc.
804804
UseCtorComdat(UseGlobalsGC && ClWithComdat && !this->CompileKernel),
805805
DestructorKind(DestructorKind),
806-
ConstructorKind(ConstructorKind) {
806+
ConstructorKind(ClConstructorKind.getNumOccurrences() > 0
807+
? ClConstructorKind
808+
: ConstructorKind) {
807809
C = &(M.getContext());
808810
int LongSize = M.getDataLayout().getPointerSizeInBits();
809811
IntptrTy = Type::getIntNTy(*C, LongSize);
@@ -1151,7 +1153,7 @@ AddressSanitizerPass::AddressSanitizerPass(
11511153
AsanCtorKind ConstructorKind)
11521154
: Options(Options), UseGlobalGC(UseGlobalGC),
11531155
UseOdrIndicator(UseOdrIndicator), DestructorKind(DestructorKind),
1154-
ConstructorKind(ClConstructorKind) {}
1156+
ConstructorKind(ConstructorKind) {}
11551157

11561158
PreservedAnalyses AddressSanitizerPass::run(Module &M,
11571159
ModuleAnalysisManager &MAM) {

0 commit comments

Comments
 (0)