@@ -614,8 +614,10 @@ static string_vector saveResultSymbolsLists(string_vector &ResSymbolsLists) {
614
614
} \
615
615
}
616
616
617
- static int processOneModule (std::unique_ptr<Module> M,
618
- util::SimpleTable &Table) {
617
+ using TableFiles = std::map<StringRef, string_vector>;
618
+
619
+ static TableFiles processOneModule (std::unique_ptr<Module> M) {
620
+ TableFiles TblFiles;
619
621
std::map<StringRef, std::vector<Function *>> GlobalsSet;
620
622
621
623
bool DoSplit = SplitMode.getNumOccurrences () > 0 ;
@@ -657,7 +659,7 @@ static int processOneModule(std::unique_ptr<Module> M,
657
659
if (IROutputOnly) {
658
660
// the result is the transformed input LLVMIR file rather than a file table
659
661
saveModule (*M, OutputFilename);
660
- return 0 ;
662
+ return TblFiles ;
661
663
}
662
664
if (DoSplit) {
663
665
splitModule (*M, GlobalsSet, ResultModules);
@@ -673,16 +675,16 @@ static int processOneModule(std::unique_ptr<Module> M,
673
675
? saveResultModules (ResultModules)
674
676
: string_vector{InputFilename};
675
677
// "Code" column is always output
676
- Error Err = Table. addColumn (COL_CODE , Files);
677
- CHECK_AND_EXIT (Err );
678
+ std::copy (Files. begin () , Files. end (),
679
+ std::back_inserter (TblFiles[COL_CODE]) );
678
680
}
679
681
680
682
{
681
683
ImagePropSaveInfo ImgPSInfo = {true , DoSpecConst, SetSpecConstAtRT,
682
684
SpecConstsMet, EmitKernelParamInfo};
683
685
string_vector Files = saveDeviceImageProperty (ResultModules, ImgPSInfo);
684
- Error Err = Table. addColumn (COL_PROPS , Files);
685
- CHECK_AND_EXIT (Err );
686
+ std::copy (Files. begin () , Files. end (),
687
+ std::back_inserter (TblFiles[COL_PROPS]) );
686
688
}
687
689
if (DoSymGen) {
688
690
// extract symbols per each module
@@ -693,10 +695,10 @@ static int processOneModule(std::unique_ptr<Module> M,
693
695
ResultSymbolsLists.push_back (" " );
694
696
}
695
697
string_vector Files = saveResultSymbolsLists (ResultSymbolsLists);
696
- Error Err = Table. addColumn (COL_SYM , Files);
697
- CHECK_AND_EXIT (Err );
698
+ std::copy (Files. begin () , Files. end (),
699
+ std::back_inserter (TblFiles[COL_SYM]) );
698
700
}
699
- return 0 ;
701
+ return TblFiles ;
700
702
}
701
703
702
704
int main (int argc, char **argv) {
@@ -789,9 +791,24 @@ int main(int argc, char **argv) {
789
791
if (OutputFilename.getNumOccurrences () == 0 )
790
792
OutputFilename = (Twine (sys::path::stem (InputFilename)) + " .files" ).str ();
791
793
794
+ TableFiles TblFiles = processOneModule (std::move (M));
792
795
util::SimpleTable Table;
793
- int Res = processOneModule (std::move (M), Table);
794
- if (Res)
796
+
797
+ auto addTableColumn = [&Table, &TblFiles](std::string Str) {
798
+ auto &Files = TblFiles[Str];
799
+ if (Files.empty ())
800
+ return 0 ;
801
+ Error Err = Table.addColumn (Str, Files);
802
+ CHECK_AND_EXIT (Err);
803
+ return 0 ;
804
+ };
805
+
806
+ int Res;
807
+ if ((Res = addTableColumn (COL_CODE)) != 0 )
808
+ return Res;
809
+ if ((Res = addTableColumn (COL_PROPS)) != 0 )
810
+ return Res;
811
+ if ((Res = addTableColumn (COL_SYM)) != 0 )
795
812
return Res;
796
813
797
814
if (IROutputOnly)
0 commit comments