Skip to content

Commit 37b8e09

Browse files
committed
[clang][fatlto] Only run sanitzer passes in prelink pipelines
FatLTO will run the sanitizer callbaks on both the pre and post link pipelines, meaning they will run twice. These passes usually have a check to prevent doing the wrong thing, but that shouldn't be relied upon, since we know these will always run as part of the prelink pipelines under FatLTO. Fixes #159629
1 parent 360b059 commit 37b8e09

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,12 @@ static void addSanitizers(const Triple &TargetTriple,
700700
const CodeGenOptions &CodeGenOpts,
701701
const LangOptions &LangOpts, PassBuilder &PB) {
702702
auto SanitizersCallback = [&](ModulePassManager &MPM, OptimizationLevel Level,
703-
ThinOrFullLTOPhase) {
703+
ThinOrFullLTOPhase phase) {
704+
// FatLTO pipelines already added these to the prelink pipeline.
705+
if (CodeGenOpts.FatLTO &&
706+
(CodeGenOpts.PrepareForThinLTO || CodeGenOpts.PrepareForLTO) &&
707+
ThinOrFullLTOPhase::None != phase)
708+
return;
704709
if (CodeGenOpts.hasSanitizeCoverage()) {
705710
auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
706711
MPM.addPass(SanitizerCoveragePass(

0 commit comments

Comments
 (0)