diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 106363fa83e2b..3ebe04e958ec4 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -700,7 +700,12 @@ static void addSanitizers(const Triple &TargetTriple, const CodeGenOptions &CodeGenOpts, const LangOptions &LangOpts, PassBuilder &PB) { auto SanitizersCallback = [&](ModulePassManager &MPM, OptimizationLevel Level, - ThinOrFullLTOPhase) { + ThinOrFullLTOPhase phase) { + // FatLTO pipelines already added these to the prelink pipeline. + if (CodeGenOpts.FatLTO && + (CodeGenOpts.PrepareForThinLTO || CodeGenOpts.PrepareForLTO) && + ThinOrFullLTOPhase::None != phase) + return; if (CodeGenOpts.hasSanitizeCoverage()) { auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts); MPM.addPass(SanitizerCoveragePass(