Skip to content

Commit 33b8865

Browse files
committed
Address some CR issues
1 parent 122425c commit 33b8865

File tree

5 files changed

+22
-17
lines changed

5 files changed

+22
-17
lines changed

llvm/include/llvm/Transforms/Utils/SYCLSplitModule.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
// of the split is new modules containing corresponding callgraph.
1111
//===----------------------------------------------------------------------===//
1212

13-
#ifndef LLVM_SYCL_SPLIT_MODULE_H
14-
#define LLVM_SYCL_SPLIT_MODULE_H
13+
#ifndef LLVM_TRANSFORMS_UTILS_SYCLSPLITMODULE_H
14+
#define LLVM_TRANSFORMS_UTILS_SYCLSPLITMODULE_H
1515

1616
#include "llvm/ADT/SmallVector.h"
1717
#include "llvm/ADT/StringRef.h"
@@ -68,4 +68,4 @@ SYCLSplitModule(std::unique_ptr<Module> M, ModuleSplitterSettings Settings);
6868

6969
} // namespace llvm
7070

71-
#endif // LLVM_SYCL_SPLIT_MODULE_H
71+
#endif // LLVM_TRANSFORMS_UTILS_SYCLSPLITMODULE_H

llvm/include/llvm/Transforms/Utils/SYCLUtils.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
#ifndef LLVM_TRANSFORMS_UTILS_SYCLUTILS_H
1111
#define LLVM_TRANSFORMS_UTILS_SYCLUTILS_H
1212

13-
#include <string>
14-
#include <vector>
13+
#include <llvm/ADT/SmallString.h>
14+
#include <llvm/ADT/SmallVector.h>
1515

1616
namespace llvm {
1717

1818
class raw_ostream;
1919

20-
using SYCLStringTable = std::vector<std::vector<std::string>>;
20+
using SYCLStringTable = SmallVector<SmallVector<SmallString<64>>>;
2121

2222
void writeSYCLStringTable(const SYCLStringTable &Table, raw_ostream &OS);
2323

llvm/lib/Transforms/Utils/SYCLSplitModule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-------- SYCLSplitModule.cpp - split a module into callgraphs --------===//
1+
//===-------- SYCLSplitModule.cpp - Split a module into call graphs -------===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.

llvm/lib/Transforms/Utils/SYCLUtils.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@ namespace llvm {
1515

1616
void writeSYCLStringTable(const SYCLStringTable &Table, raw_ostream &OS) {
1717
assert(Table.size() > 0 && "table should contain at least column titles");
18-
size_t numberColumns = Table[0].size();
19-
assert(numberColumns > 0 && "table should be non-empty");
18+
assert(Table[0].size() > 0 && "table should be non-empty");
2019
OS << '[' << join(Table[0].begin(), Table[0].end(), "|") << "]\n";
2120
for (size_t I = 1, E = Table.size(); I != E; ++I) {
22-
assert(Table[I].size() == numberColumns && "row's size should be equal");
21+
assert(Table[I].size() == Table[0].size() && "row's size should be equal");
2322
OS << join(Table[I].begin(), Table[I].end(), "|") << '\n';
2423
}
2524
}

llvm/tools/llvm-split/llvm-split.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
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"
@@ -32,9 +34,6 @@
3234
#include "llvm/Transforms/Utils/SYCLUtils.h"
3335
#include "llvm/Transforms/Utils/SplitModule.h"
3436

35-
#include <string>
36-
#include <vector>
37-
3837
using namespace llvm;
3938

4039
static cl::OptionCategory SplitCategory("Split Options");
@@ -90,7 +89,7 @@ static cl::opt<IRSplitMode> SYCLSplitMode(
9089
static 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

104103
void 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

Comments
 (0)