[llvm] [profcheck] Don't verify generated global ctors/dtors (PR #170597)
Mircea Trofin via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 4 12:54:02 PST 2025
================
@@ -189,11 +195,43 @@ PreservedAnalyses ProfileInjectorPass::run(Function &F,
return PreservedAnalyses::none();
}
+PreservedAnalyses ProfileVerifierPass::run(Module &M,
+ ModuleAnalysisManager &MAM) {
+ auto PopulateIgnoreList = [&](StringRef GVName) {
+ if (const auto *CT = M.getGlobalVariable(GVName))
+ if (const auto *CA =
+ dyn_cast_if_present<ConstantArray>(CT->getInitializer()))
+ for (const auto &Elt : CA->operands())
+ if (const auto *CS = dyn_cast<ConstantStruct>(Elt))
+ if (CS->getNumOperands() >= 2 && CS->getOperand(1))
+ if (const auto *F = dyn_cast<Function>(
+ CS->getOperand(1)->stripPointerCasts()))
+ IgnoreList.insert(F);
+ };
+ PopulateIgnoreList("llvm.global_ctors");
+ PopulateIgnoreList("llvm.global_dtors");
+
+ // expose the function-level run as public through a wrapper, so we can use
+ // pass manager mechanisms dealing with declarations and with composing the
+ // returned PreservedAnalyses values.
+ struct Wrapper : PassInfoMixin<Wrapper> {
+ ProfileVerifierPass &PVP;
+ PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM) {
+ return PVP.run(F, FAM);
+ }
+ explicit Wrapper(ProfileVerifierPass &PVP) : PVP(PVP) {}
+ };
+
+ return createModuleToFunctionPassAdaptor(Wrapper(*this)).run(M, MAM);
+}
+
PreservedAnalyses ProfileVerifierPass::run(Function &F,
----------------
mtrofin wrote:
that one is right, the change is for the verifier.
https://github.com/llvm/llvm-project/pull/170597
More information about the llvm-commits
mailing list