Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion clang/include/clang/Basic/LangOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,8 @@ class LangOptions : public LangOptionsBase {
Cilktool_None = 0,
Cilktool_Cilkscale,
Cilktool_Cilkscale_InstructionCount,
Cilktool_Cilkscale_Benchmark
Cilktool_Cilkscale_Benchmark,
Cilktool_Cilkgraph
};

enum CilkVersion {
Expand Down
23 changes: 23 additions & 0 deletions clang/lib/CodeGen/BackendUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,20 @@ static CSIOptions getCSIOptionsForCilkscaleBenchmark() {
return Options;
}

static CSIOptions getCSIOptionsForCilkgraph() {
CSIOptions Options;
// Disable CSI hooks that Cilkgraph doesn't need.
Options.InstrumentLoops = false;
// Options.InstrumentBasicBlocks = false;
Options.InstrumentMemoryAccesses = false;
Options.InstrumentCalls = false;
Options.InstrumentAtomics = false;
Options.InstrumentMemIntrinsics = false;
Options.InstrumentAllocas = false;
Options.InstrumentAllocFns = false;
return Options;
}

static TargetLibraryInfoImpl *createTLII(llvm::Triple &TargetTriple,
const CodeGenOptions &CodeGenOpts) {
TargetLibraryInfoImpl *TLII = new TargetLibraryInfoImpl(TargetTriple);
Expand Down Expand Up @@ -1096,6 +1110,15 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
MPM.addPass(PB.buildPostCilkInstrumentationPipeline(Level));
});
break;
case LangOptions::CilktoolKind::Cilktool_Cilkgraph:
PB.registerTapirLoopEndEPCallback(
[&PB](ModulePassManager &MPM, OptimizationLevel Level) {
MPM.addPass(CSISetupPass(getCSIOptionsForCilkgraph()));
MPM.addPass(ComprehensiveStaticInstrumentationPass(
getCSIOptionsForCilkgraph()));
MPM.addPass(PB.buildPostCilkInstrumentationPipeline(Level));
});
break;
}
}
// Register the CSI pass.
Expand Down
4 changes: 4 additions & 0 deletions clang/lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1314,6 +1314,7 @@ parseCilktoolKind(StringRef FlagName, ArgList &Args, DiagnosticsEngine &Diags) {
LangOptions::Cilktool_Cilkscale_InstructionCount)
.Case("cilkscale-benchmark",
LangOptions::Cilktool_Cilkscale_Benchmark)
.Case("cilkgraph", LangOptions::Cilktool_Cilkgraph)
.Default(LangOptions::Cilktool_None);
if (ParsedCilktool == LangOptions::Cilktool_None)
Diags.Report(diag::err_drv_invalid_value) << FlagName << Val;
Expand All @@ -1336,6 +1337,9 @@ serializeCilktoolKind(LangOptions::CilktoolKind K) {
case LangOptions::Cilktool_Cilkscale_Benchmark:
CilktoolStr = "cilkscale-benchmark";
break;
case LangOptions::Cilktool_Cilkgraph:
CilktoolStr = "cilkgraph";
break;
case LangOptions::Cilktool_None:
break;
}
Expand Down
3 changes: 3 additions & 0 deletions clang/lib/Frontend/InitPreprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1340,6 +1340,9 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
case LangOptions::CilktoolKind::Cilktool_Cilkscale_Benchmark:
Builder.defineMacro("__cilkscale__");
break;
case LangOptions::CilktoolKind::Cilktool_Cilkgraph:
Builder.defineMacro("__cilkgraph__");
break;
default: break;
}

Expand Down