@@ -169,7 +169,6 @@ cl::opt<std::string>
169169
170170cl::opt<std::string> ProjectIdOpt (" project-id" ,
171171 cl::desc (" Project id used for output" ),
172- cl::init(" default-phasar-project" ),
173172 cl::cat(PsrCat), cl::Hidden);
174173
175174PSR_SHORTLONG_OPTION (OutDirOpt, std::string, " O" , " out" ,
@@ -233,6 +232,12 @@ cl::opt<std::string>
233232 " via emit-pta-as-json from the given file" ),
234233 cl::cat(PsrCat));
235234
235+ cl::opt<std::string> LoadCGFromJsonOpt (
236+ " load-cg-from-json" ,
237+ cl::desc (" Load the persisted call-graph previously exported via "
238+ " emit-cg-as-json from the given file" ),
239+ cl::cat(PsrCat));
240+
236241PSR_SHORTLONG_OPTION (PammOutOpt, std::string, " A" , " pamm-out" ,
237242 " Filename for PAMM's gathered data" ,
238243 cl::init (" PAMM_data.json" ), cl::cat(PsrCat), cl::Hidden);
@@ -344,6 +349,15 @@ int main(int Argc, const char **Argv) {
344349 return 1 ;
345350 }
346351
352+ if (ProjectIdOpt.empty ()) {
353+ ProjectIdOpt = std::filesystem::path (ModuleOpt.getValue ())
354+ .filename ()
355+ .replace_extension ();
356+ if (ProjectIdOpt.empty ()) {
357+ ProjectIdOpt = " default-phasar-project" ;
358+ }
359+ }
360+
347361 validateParamModule ();
348362 validateParamOutput ();
349363 validateParamPointerAnalysis ();
@@ -385,6 +399,15 @@ int main(int Argc, const char **Argv) {
385399 if (EmitCGAsDotOpt) {
386400 EmitterOptions |= AnalysisControllerEmitterOptions::EmitCGAsDot;
387401 }
402+ if (EmitCGAsJsonOpt) {
403+ EmitterOptions |= AnalysisControllerEmitterOptions::EmitCGAsJson;
404+ }
405+ if (EmitCGAsTextOpt) {
406+ llvm::errs ()
407+ << " ERROR: emit-cg-as-text is currently not supported. Did you mean "
408+ " emit-cg-as-dot? For reversible serialization use emit-cg-as-json\n " ;
409+ return 1 ;
410+ }
388411 if (EmitPTAAsTextOpt) {
389412 EmitterOptions |= AnalysisControllerEmitterOptions::EmitPTAAsText;
390413 }
@@ -410,9 +433,16 @@ int main(int Argc, const char **Argv) {
410433
411434 std::optional<nlohmann::json> PrecomputedAliasSet;
412435 if (!LoadPTAFromJsonOpt.empty ()) {
436+ PHASAR_LOG_LEVEL (INFO, " Load AliasInfo from file: " << LoadCGFromJsonOpt);
413437 PrecomputedAliasSet = readJsonFile (LoadPTAFromJsonOpt);
414438 }
415439
440+ std::optional<nlohmann::json> PrecomputedCallGraph;
441+ if (!LoadCGFromJsonOpt.empty ()) {
442+ PHASAR_LOG_LEVEL (INFO, " Load CallGraph from file: " << LoadCGFromJsonOpt);
443+ PrecomputedCallGraph = readJsonFile (LoadCGFromJsonOpt);
444+ }
445+
416446 if (EntryOpt.empty ()) {
417447 EntryOpt.push_back (" main" );
418448 }
@@ -421,7 +451,8 @@ int main(int Argc, const char **Argv) {
421451 HelperAnalyses HA (std::move (ModuleOpt.getValue ()),
422452 std::move (PrecomputedAliasSet), AliasTypeOpt,
423453 !AnalysisController::needsToEmitPTA (EmitterOptions),
424- EntryOpt, CGTypeOpt, SoundnessOpt, AutoGlobalsOpt);
454+ EntryOpt, std::move (PrecomputedCallGraph), CGTypeOpt,
455+ SoundnessOpt, AutoGlobalsOpt);
425456
426457 AnalysisController Controller (
427458 HA, DataFlowAnalysisOpt, {AnalysisConfigOpt.getValue ()}, EntryOpt,
0 commit comments