Skip to content

Commit

Permalink
[clang] Fix handling of Cilkscale tool variants, specifically cilksca…
Browse files Browse the repository at this point in the history
…le and cilkscale-instructions, to ensure instrumentation is inserted appropriately when using LLD with LTO.
  • Loading branch information
neboat committed Dec 7, 2024
1 parent 80676cb commit 09c0b71
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/BackendUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
});
break;
case LangOptions::CilktoolKind::Cilktool_Cilkscale_Benchmark:
PB.registerTapirLoopEndEPCallback(
PB.registerTapirLateEPCallback(
[&PB](ModulePassManager &MPM, OptimizationLevel Level) {
MPM.addPass(CSISetupPass(getCSIOptionsForCilkscaleBenchmark()));
MPM.addPass(ComprehensiveStaticInstrumentationPass(
Expand Down
4 changes: 4 additions & 0 deletions clang/lib/Driver/ToolChains/CommonArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,10 @@ static void renderTapirLoweringOptions(const ArgList &Args,
} else if (Args.hasArg(options::OPT_fcilkplus))
CmdArgs.push_back("--plugin-opt=tapir-target=cilkplus");
}

if (const Arg *A = Args.getLastArg(options::OPT_fcilktool_EQ))
CmdArgs.push_back(Args.MakeArgString(
Twine("--plugin-opt=cilktool=") + A->getValue()));
}

void tools::addPathIfExists(const Driver &D, const Twine &Path,
Expand Down
4 changes: 4 additions & 0 deletions clang/lib/Driver/ToolChains/Darwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,10 @@ static void renderTapirLoweringOptions(const ArgList &Args,
} else if (Args.hasArg(options::OPT_fcilkplus))
CmdArgs.push_back("--tapir-target=cilkplus");
}

if (const Arg *A = Args.getLastArg(options::OPT_fcilktool_EQ))
CmdArgs.push_back(
Args.MakeArgString(Twine("--plugin-opt=cilktool=") + A->getValue()));
}

static void AppendPlatformPrefix(SmallString<128> &Path, const llvm::Triple &T);
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Passes/PassBuilderPipelines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1777,7 +1777,7 @@ PassBuilder::buildPerModuleDefaultPipeline(OptimizationLevel Level,
MPM.addPass(buildTapirLoweringPipeline(
Level, LTOPreLink ? ThinOrFullLTOPhase::FullLTOPreLink
: ThinOrFullLTOPhase::None));
else
else if (!LTOPreLink)
invokeTapirLoopEndEPCallbacks(MPM, Level);

return MPM;
Expand Down Expand Up @@ -2359,7 +2359,7 @@ ModulePassManager PassBuilder::buildO0DefaultPipeline(OptimizationLevel Level,
MPM.addPass(buildTapirLoweringPipeline(
Level, LTOPreLink ? ThinOrFullLTOPhase::FullLTOPreLink
: ThinOrFullLTOPhase::None));
else
else if (!LTOPreLink)
invokeTapirLoopEndEPCallbacks(MPM, Level);

invokeOptimizerLastEPCallbacks(MPM, Level);
Expand Down

0 comments on commit 09c0b71

Please sign in to comment.