1111//
1212// ===----------------------------------------------------------------------===//
1313
14+ #include " llvm/ADT/SmallString.h"
15+ #include " llvm/ADT/SmallVector.h"
1416#include " llvm/ADT/StringExtras.h"
1517#include " llvm/Bitcode/BitcodeWriter.h"
1618#include " llvm/IR/LLVMContext.h"
3234#include " llvm/Transforms/Utils/SYCLUtils.h"
3335#include " llvm/Transforms/Utils/SplitModule.h"
3436
35- #include < string>
36- #include < vector>
37-
3837using namespace llvm ;
3938
4039static cl::OptionCategory SplitCategory (" Split Options" );
@@ -90,7 +89,7 @@ static cl::opt<IRSplitMode> SYCLSplitMode(
9089static cl::opt<bool > OutputAssembly{
9190 " S" , cl::desc (" Write output as LLVM assembly" ), cl::cat (SplitCategory)};
9291
93- void writeStringToFile (std::string_view Content, StringRef Path) {
92+ void writeStringToFile (StringRef Content, StringRef Path) {
9493 std::error_code EC;
9594 raw_fd_ostream OS (Path, EC);
9695 if (EC) {
@@ -103,13 +102,19 @@ void writeStringToFile(std::string_view Content, StringRef Path) {
103102
104103void writeSplitModulesAsTable (ArrayRef<ModuleAndSYCLMetadata> Modules,
105104 StringRef Path) {
106- std::vector<std::string> Columns = {" Code" , " Symbols" };
105+ SmallVector<SmallString<64 >> Columns;
106+ Columns.emplace_back (" Code" );
107+ Columns.emplace_back (" Symbols" );
108+
107109 SYCLStringTable Table;
108110 Table.emplace_back (std::move (Columns));
109111 for (const auto &[I, SM] : enumerate(Modules)) {
110- std::string SymbolsFile = (Twine (Path) + " _" + Twine (I) + " .sym" ).str ();
112+ SmallString<128 > SymbolsFile;
113+ (Twine (Path) + " _" + Twine (I) + " .sym" ).toVector (SymbolsFile);
111114 writeStringToFile (SM.Symbols , SymbolsFile);
112- std::vector<std::string> Row = {SM.ModuleFilePath , SymbolsFile};
115+ SmallVector<SmallString<64 >> Row;
116+ Row.emplace_back (SM.ModuleFilePath );
117+ Row.emplace_back (SymbolsFile);
113118 Table.emplace_back (std::move (Row));
114119 }
115120
@@ -194,6 +199,7 @@ int main(int argc, char **argv) {
194199 if (E) {
195200 errs () << E << " \n " ;
196201 Err.print (argv[0 ], errs ());
202+ return 1 ;
197203 }
198204
199205 return 0 ;
0 commit comments