[compiler-rt] [llvm] [asan] Limit priority of ctor to kMax-1 (PR #101772)
Florian Mayer via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 2 17:05:59 PDT 2024
================
@@ -1993,6 +1994,29 @@ void ModuleAddressSanitizer::createInitializerPoisonCalls(
poisonOneInitializer(*F, ModuleName);
}
}
+ assert(ClInitializers);
+ updateGlobalCtors(M, [](Constant *C) -> Constant * {
+ ConstantStruct *CS = dyn_cast<ConstantStruct>(C);
+ if (!CS)
+ return C;
+ auto *Priority = cast<ConstantInt>(CS->getOperand(0));
+ if (Priority->getLimitedValue() != kMaxCtorAndDtorPriority)
+ return C;
+ // As optimization, runtime needs to execute callback just after all
+ // constructors. We going to set priority to the max allowed value. However,
+ // the default constructor priorily is already max, so as-is we will not be
+ // able to guaranty desired order. So reduce the priority by one to reserve
+ // max value for the constructor in runtime.
----------------
fmayer wrote:
I will note that this could theoretically break user-code that depends on the order between `max` and `max-1`
https://github.com/llvm/llvm-project/pull/101772
More information about the llvm-commits
mailing list