Skip to content

Commit bff0a3c

Browse files
committed
cilkgraph computation DAG generation tool
1 parent 03a724d commit bff0a3c

4 files changed

Lines changed: 32 additions & 1 deletion

File tree

clang/include/clang/Basic/LangOptions.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,8 @@ class LangOptions : public LangOptionsBase {
398398
Cilktool_None = 0,
399399
Cilktool_Cilkscale,
400400
Cilktool_Cilkscale_InstructionCount,
401-
Cilktool_Cilkscale_Benchmark
401+
Cilktool_Cilkscale_Benchmark,
402+
Cilktool_Cilkgraph
402403
};
403404

404405
enum CilkVersion {

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,20 @@ static CSIOptions getCSIOptionsForCilkscaleBenchmark() {
300300
return Options;
301301
}
302302

303+
static CSIOptions getCSIOptionsForCilkgraph() {
304+
CSIOptions Options;
305+
// Disable CSI hooks that Cilkgraph doesn't need.
306+
Options.InstrumentLoops = false;
307+
// Options.InstrumentBasicBlocks = false;
308+
Options.InstrumentMemoryAccesses = false;
309+
Options.InstrumentCalls = false;
310+
Options.InstrumentAtomics = false;
311+
Options.InstrumentMemIntrinsics = false;
312+
Options.InstrumentAllocas = false;
313+
Options.InstrumentAllocFns = false;
314+
return Options;
315+
}
316+
303317
static TargetLibraryInfoImpl *createTLII(llvm::Triple &TargetTriple,
304318
const CodeGenOptions &CodeGenOpts) {
305319
TargetLibraryInfoImpl *TLII = new TargetLibraryInfoImpl(TargetTriple);
@@ -1064,6 +1078,15 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
10641078
MPM.addPass(PB.buildPostCilkInstrumentationPipeline(Level));
10651079
});
10661080
break;
1081+
case LangOptions::CilktoolKind::Cilktool_Cilkgraph:
1082+
PB.registerTapirLoopEndEPCallback(
1083+
[&PB](ModulePassManager &MPM, OptimizationLevel Level) {
1084+
MPM.addPass(CSISetupPass(getCSIOptionsForCilkgraph()));
1085+
MPM.addPass(ComprehensiveStaticInstrumentationPass(
1086+
getCSIOptionsForCilkgraph()));
1087+
MPM.addPass(PB.buildPostCilkInstrumentationPipeline(Level));
1088+
});
1089+
break;
10671090
}
10681091
}
10691092
// Register the CSI pass.

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,6 +1287,7 @@ parseCilktoolKind(StringRef FlagName, ArgList &Args, DiagnosticsEngine &Diags) {
12871287
LangOptions::Cilktool_Cilkscale_InstructionCount)
12881288
.Case("cilkscale-benchmark",
12891289
LangOptions::Cilktool_Cilkscale_Benchmark)
1290+
.Case("cilkgraph", LangOptions::Cilktool_Cilkgraph)
12901291
.Default(LangOptions::Cilktool_None);
12911292
if (ParsedCilktool == LangOptions::Cilktool_None)
12921293
Diags.Report(diag::err_drv_invalid_value) << FlagName << Val;
@@ -1309,6 +1310,9 @@ serializeCilktoolKind(LangOptions::CilktoolKind K) {
13091310
case LangOptions::Cilktool_Cilkscale_Benchmark:
13101311
CilktoolStr = "cilkscale-benchmark";
13111312
break;
1313+
case LangOptions::Cilktool_Cilkgraph:
1314+
CilktoolStr = "cilkgraph";
1315+
break;
13121316
case LangOptions::Cilktool_None:
13131317
break;
13141318
}

clang/lib/Frontend/InitPreprocessor.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,6 +1316,9 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
13161316
case LangOptions::CilktoolKind::Cilktool_Cilkscale_Benchmark:
13171317
Builder.defineMacro("__cilkscale__");
13181318
break;
1319+
case LangOptions::CilktoolKind::Cilktool_Cilkgraph:
1320+
Builder.defineMacro("__cilkgraph__");
1321+
break;
13191322
default: break;
13201323
}
13211324

0 commit comments

Comments
 (0)