Skip to content

Commit c6710c5

Browse files
committed
clang-format
1 parent d77bf6e commit c6710c5

File tree

10 files changed

+99
-74
lines changed

10 files changed

+99
-74
lines changed

llvm/include/llvm/InitializePasses.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ void initializeStripSymbolsPass(PassRegistry&);
432432
void initializeStructurizeCFGLegacyPassPass(PassRegistry &);
433433
void initializeSYCLLowerWGScopeLegacyPassPass(PassRegistry &);
434434
void initializeSYCLLowerESIMDLegacyPassPass(PassRegistry &);
435-
void initializeSYCLLowerESIMDKernelPropsLegacyPassPass(PassRegistry&);
435+
void initializeSYCLLowerESIMDKernelPropsLegacyPassPass(PassRegistry &);
436436
void initializeSYCLLowerInvokeSimdLegacyPassPass(PassRegistry &);
437437
void initializeSYCLMutatePrintfAddrspaceLegacyPassPass(PassRegistry &);
438438
void initializeSPIRITTAnnotationsLegacyPassPass(PassRegistry &);

llvm/include/llvm/SYCLLowerIR/ESIMD/ESIMDUtils.h

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,23 @@ namespace esimd {
1717

1818
constexpr char ATTR_DOUBLE_GRF[] = "esimd-double-grf";
1919

20-
using CallGraphNodeAction = std::function<void(Function*)>;
21-
void traverseCallgraphUp(llvm::Function* F, CallGraphNodeAction NodeF, bool ErrorOnNonCallUse);
22-
23-
// Traverses call graph starting from given function up the call chain applying given action
24-
// to each function met on the way. If \c ErrorOnNonCallUse parameter is true, then no
25-
// functions' uses are allowed except calls. Otherwise, any function where use of the
26-
// current one happened is added to the call graph as if the use was a call.
20+
using CallGraphNodeAction = std::function<void(Function *)>;
21+
void traverseCallgraphUp(llvm::Function *F, CallGraphNodeAction NodeF,
22+
bool ErrorOnNonCallUse);
23+
24+
// Traverses call graph starting from given function up the call chain applying
25+
// given action to each function met on the way. If \c ErrorOnNonCallUse
26+
// parameter is true, then no functions' uses are allowed except calls.
27+
// Otherwise, any function where use of the current one happened is added to the
28+
// call graph as if the use was a call.
2729
template <class CallGraphNodeActionF>
28-
void traverseCallgraphUp(Function* F, CallGraphNodeActionF ActionF, bool ErrorOnNonCallUse = true) {
29-
traverseCallgraphUp(F, CallGraphNodeAction{ ActionF }, ErrorOnNonCallUse);
30+
void traverseCallgraphUp(Function *F, CallGraphNodeActionF ActionF,
31+
bool ErrorOnNonCallUse = true) {
32+
traverseCallgraphUp(F, CallGraphNodeAction{ActionF}, ErrorOnNonCallUse);
3033
}
3134

3235
// Tells whether given function is a ESIMD kernel.
33-
bool isESIMDKernel(const Function& F);
36+
bool isESIMDKernel(const Function &F);
3437

3538
} // namespace esimd
3639
} // namespace llvm

llvm/include/llvm/SYCLLowerIR/ESIMD/LowerESIMD.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,10 @@ ModulePass *createESIMDLowerVecArgPass();
7070
void initializeESIMDLowerVecArgLegacyPassPass(PassRegistry &);
7171

7272
// Lowers calls to __esimd_set_kernel_properties
73-
class SYCLLowerESIMDKernelPropsPass : public PassInfoMixin<SYCLLowerESIMDKernelPropsPass> {
73+
class SYCLLowerESIMDKernelPropsPass
74+
: public PassInfoMixin<SYCLLowerESIMDKernelPropsPass> {
7475
public:
75-
PreservedAnalyses run(Module& M, ModuleAnalysisManager&);
76+
PreservedAnalyses run(Module &M, ModuleAnalysisManager &);
7677
};
7778

7879
} // namespace llvm

llvm/lib/SYCLLowerIR/ESIMD/ESIMDUtils.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88
namespace llvm {
99
namespace esimd {
1010

11-
void traverseCallgraphUp(llvm::Function* F, CallGraphNodeAction ActionF, bool ErrorOnNonCallUse) {
12-
SmallPtrSet<Function*, 32> FunctionsVisited;
13-
SmallVector<Function*, 32> Worklist{ F };
11+
void traverseCallgraphUp(llvm::Function *F, CallGraphNodeAction ActionF,
12+
bool ErrorOnNonCallUse) {
13+
SmallPtrSet<Function *, 32> FunctionsVisited;
14+
SmallVector<Function *, 32> Worklist{F};
1415

1516
while (!Worklist.empty()) {
16-
Function* CurF = Worklist.pop_back_val();
17+
Function *CurF = Worklist.pop_back_val();
1718
FunctionsVisited.insert(CurF);
1819
// Apply the action function.
1920
ActionF(CurF);
@@ -26,12 +27,12 @@ void traverseCallgraphUp(llvm::Function* F, CallGraphNodeAction ActionF, bool Er
2627
if (ErrorOnNonCallUse) {
2728
// ... non-call is an error - report
2829
llvm::report_fatal_error(
29-
llvm::Twine(__FILE__ " ") +
30-
"Function use other than call detected while traversing call\n"
31-
"graph up to a kernel");
30+
llvm::Twine(__FILE__ " ") +
31+
"Function use other than call detected while traversing call\n"
32+
"graph up to a kernel");
3233
} else {
3334
// ... non-call is OK - add using function to the worklist
34-
if (auto* I = dyn_cast<Instruction>(FCall)) {
35+
if (auto *I = dyn_cast<Instruction>(FCall)) {
3536
auto UseF = I->getFunction();
3637

3738
if (!FunctionsVisited.count(UseF)) {
@@ -50,11 +51,10 @@ void traverseCallgraphUp(llvm::Function* F, CallGraphNodeAction ActionF, bool Er
5051
}
5152
}
5253

53-
bool isESIMDKernel(const Function& F) {
54+
bool isESIMDKernel(const Function &F) {
5455
return (F.getCallingConv() == CallingConv::SPIR_KERNEL) &&
55-
(F.getMetadata("sycl_explicit_simd") != nullptr);
56+
(F.getMetadata("sycl_explicit_simd") != nullptr);
5657
}
5758

5859
} // namespace esimd
5960
} // namespace llvm
60-

llvm/lib/SYCLLowerIR/ESIMD/LowerESIMD.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
// values of integer template parameters they were instantiated with.
1414
//===----------------------------------------------------------------------===//
1515

16-
#include "llvm/SYCLLowerIR/ESIMD/ESIMDUtils.h"
1716
#include "llvm/SYCLLowerIR/ESIMD/LowerESIMD.h"
17+
#include "llvm/SYCLLowerIR/ESIMD/ESIMDUtils.h"
1818

1919
#include "llvm/ADT/DenseMap.h"
2020
#include "llvm/ADT/DenseSet.h"
@@ -72,7 +72,8 @@ class SYCLLowerESIMDLegacyPass : public ModulePass {
7272

7373
char SYCLLowerESIMDLegacyPass::ID = 0;
7474
INITIALIZE_PASS(SYCLLowerESIMDLegacyPass, "LowerESIMD",
75-
"Lower constructs specific to the 'explicit SIMD' extension", false, false)
75+
"Lower constructs specific to the 'explicit SIMD' extension",
76+
false, false)
7677

7778
// Public interface to the SYCLLowerESIMDPass.
7879
ModulePass *llvm::createSYCLLowerESIMDPass() {
@@ -1760,7 +1761,8 @@ size_t SYCLLowerESIMDPass::runOnFunction(Function &F,
17601761
ToErase.push_back(CI);
17611762
continue;
17621763
}
1763-
assert(!Name.startswith("__esimd_set_kernel_properties") && "__esimd_set_kernel_properties must have been lowered");
1764+
assert(!Name.startswith("__esimd_set_kernel_properties") &&
1765+
"__esimd_set_kernel_properties must have been lowered");
17641766

17651767
if (Name.empty() || !Name.startswith(ESIMD_INTRIN_PREF1))
17661768
continue;

llvm/lib/SYCLLowerIR/ESIMD/LowerESIMDKernelProps.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
// function attributes and adds those attributes to all kernels which can
1010
// potentially call this intrinsic.
1111

12-
#include "llvm/SYCLLowerIR/ESIMD/LowerESIMD.h"
1312
#include "llvm/SYCLLowerIR/ESIMD/ESIMDUtils.h"
13+
#include "llvm/SYCLLowerIR/ESIMD/LowerESIMD.h"
1414

1515
#include "llvm/ADT/SmallPtrSet.h"
1616
#include "llvm/IR/Instructions.h"
@@ -24,7 +24,8 @@ using namespace llvm;
2424

2525
namespace {
2626

27-
constexpr char SET_KERNEL_PROPS_FUNC_NAME[] = "_Z29__esimd_set_kernel_propertiesi";
27+
constexpr char SET_KERNEL_PROPS_FUNC_NAME[] =
28+
"_Z29__esimd_set_kernel_propertiesi";
2829

2930
// Kernel property identifiers. Should match ones in
3031
// sycl/include/sycl/ext/intel/experimental/esimd/kernel_properties.hpp
@@ -36,8 +37,8 @@ void processSetKernelPropertiesCall(CallInst &CI) {
3637

3738
if (!isa<ConstantInt>(ArgV)) {
3839
llvm::report_fatal_error(
39-
llvm::Twine(__FILE__ " ") +
40-
"integral constant is expected for set_kernel_properties");
40+
llvm::Twine(__FILE__ " ") +
41+
"integral constant is expected for set_kernel_properties");
4142
}
4243
uint64_t PropID = cast<llvm::ConstantInt>(ArgV)->getZExtValue();
4344

@@ -57,9 +58,9 @@ void processSetKernelPropertiesCall(CallInst &CI) {
5758
} // namespace
5859

5960
namespace llvm {
60-
PreservedAnalyses SYCLLowerESIMDKernelPropsPass::run(Module &M,
61-
ModuleAnalysisManager &MAM) {
62-
Function* F = M.getFunction(SET_KERNEL_PROPS_FUNC_NAME);
61+
PreservedAnalyses
62+
SYCLLowerESIMDKernelPropsPass::run(Module &M, ModuleAnalysisManager &MAM) {
63+
Function *F = M.getFunction(SET_KERNEL_PROPS_FUNC_NAME);
6364

6465
if (!F) {
6566
return PreservedAnalyses::all();

llvm/tools/sycl-post-link/ModuleSplitter.cpp

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,10 @@ groupEntryPointsByKernelType(const Module &M, bool EmitOnlyKernelsAsEntryPoints,
161161
}
162162

163163
if (!EntryPointMap.empty()) {
164-
for (auto& EPG : EntryPointMap) {
164+
for (auto &EPG : EntryPointMap) {
165165
EntryPointGroups.emplace_back(
166166
EntryPointGroup{EPG.first, std::move(EPG.second), BlueprintProps});
167-
EntryPointGroup& G = EntryPointGroups.back();
167+
EntryPointGroup &G = EntryPointGroups.back();
168168

169169
if (G.GroupId == ESIMD_SCOPE_NAME) {
170170
G.Props.HasESIMD = SyclEsimdSplitStatus::ESIMD_ONLY;
@@ -176,7 +176,7 @@ groupEntryPointsByKernelType(const Module &M, bool EmitOnlyKernelsAsEntryPoints,
176176
} else {
177177
// No entry points met, record this.
178178
EntryPointGroups.emplace_back(EntryPointGroup{SYCL_SCOPE_NAME, {}});
179-
EntryPointGroup& G = EntryPointGroups.back();
179+
EntryPointGroup &G = EntryPointGroups.back();
180180
G.Props.HasESIMD = SyclEsimdSplitStatus::SYCL_ONLY;
181181
}
182182

@@ -231,10 +231,10 @@ groupEntryPointsByScope(const Module &M, EntryPointsGroupScope EntryScope,
231231

232232
if (!EntryPointMap.empty()) {
233233
EntryPointGroups.reserve(EntryPointMap.size());
234-
for (auto& EPG : EntryPointMap) {
234+
for (auto &EPG : EntryPointMap) {
235235
EntryPointGroups.emplace_back(
236236
EntryPointGroup{EPG.first, std::move(EPG.second), BlueprintProps});
237-
EntryPointGroup& G = EntryPointGroups.back();
237+
EntryPointGroup &G = EntryPointGroups.back();
238238
G.Props.Scope = EntryScope;
239239
}
240240
} else {
@@ -264,7 +264,7 @@ EntryPointGroupVec groupEntryPointsByAttribute(
264264
}
265265
if (!EntryPointMap.empty()) {
266266
EntryPointGroups.reserve(EntryPointMap.size());
267-
for (auto& EPG : EntryPointMap) {
267+
for (auto &EPG : EntryPointMap) {
268268
EntryPointGroups.emplace_back(
269269
EntryPointGroup{EPG.first, std::move(EPG.second), BlueprintProps});
270270
F(EntryPointGroups.back());
@@ -281,29 +281,32 @@ EntryPointGroupVec groupEntryPointsByAttribute(
281281
// edges are "calls" relation.
282282
class CallGraph {
283283
public:
284-
using FunctionSet = SmallPtrSet<const Function*, 16>;
284+
using FunctionSet = SmallPtrSet<const Function *, 16>;
285285

286286
private:
287-
std::unordered_map<const Function*, FunctionSet> Graph;
288-
SmallPtrSet<const Function*, 1> EmptySet;
287+
std::unordered_map<const Function *, FunctionSet> Graph;
288+
SmallPtrSet<const Function *, 1> EmptySet;
289289

290290
public:
291291
CallGraph(const Module &M) {
292-
for (const auto& F : M) {
293-
for (const Value* U : F.users()) {
292+
for (const auto &F : M) {
293+
for (const Value *U : F.users()) {
294294
if (const auto *I = dyn_cast<CallInst>(U)) {
295295
if (I->getCalledFunction() == &F) {
296-
const Function* F1 = I->getFunction();
296+
const Function *F1 = I->getFunction();
297297
Graph[F1].insert(&F);
298298
}
299299
}
300300
}
301301
}
302302
}
303303

304-
iterator_range<FunctionSet::const_iterator> successors(const Function* F) const {
304+
iterator_range<FunctionSet::const_iterator>
305+
successors(const Function *F) const {
305306
auto It = Graph.find(F);
306-
return (It == Graph.end()) ? make_range(EmptySet.begin(), EmptySet.end()) : make_range(It->second.begin(), It->second.end());
307+
return (It == Graph.end())
308+
? make_range(EmptySet.begin(), EmptySet.end())
309+
: make_range(It->second.begin(), It->second.end());
307310
}
308311
};
309312

@@ -319,7 +322,7 @@ void collectFunctionsToExtract(SetVector<const GlobalValue *> &GVs,
319322
while (Idx < GVs.size()) {
320323
const auto *F = cast<Function>(GVs[Idx++]);
321324

322-
for (const Function* F1 : Deps.successors(F)) {
325+
for (const Function *F1 : Deps.successors(F)) {
323326
if (!F1->isDeclaration())
324327
GVs.insert(F1);
325328
}
@@ -550,7 +553,8 @@ void dumpEntryPoints(const Module &M, bool OnlyKernelsAreEntryPoints,
550553
llvm::errs() << "}\n";
551554
}
552555

553-
void ModuleDesc::assignMergedProperties(const ModuleDesc& MD1, const ModuleDesc& MD2) {
556+
void ModuleDesc::assignMergedProperties(const ModuleDesc &MD1,
557+
const ModuleDesc &MD2) {
554558
EntryPoints.Props = MD1.EntryPoints.Props.merge(MD2.EntryPoints.Props);
555559
Props.SpecConstsMet = MD1.Props.SpecConstsMet || MD2.Props.SpecConstsMet;
556560
}
@@ -626,8 +630,8 @@ void ModuleDesc::dump() {
626630
llvm::errs() << "split_module::ModuleDesc[" << Name << "] {\n";
627631
llvm::errs() << " ESIMD:" << toString(EntryPoints.Props.HasESIMD)
628632
<< ", SpecConstMet:" << (Props.SpecConstsMet ? "YES" : "NO")
629-
<< ", DoubleGRF:" << (EntryPoints.Props.UsesDoubleGRF ? "YES" : "NO")
630-
<< "\n";
633+
<< ", DoubleGRF:"
634+
<< (EntryPoints.Props.UsesDoubleGRF ? "YES" : "NO") << "\n";
631635
dumpEntryPoints(entries(), EntryPoints.GroupId.str().c_str(), 1);
632636
llvm::errs() << "}\n";
633637
}

llvm/tools/sycl-post-link/ModuleSplitter.h

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,11 @@ struct EntryPointGroup {
5959
// Scope represented by EPs in a group
6060
EntryPointsGroupScope Scope = Scope_Global;
6161

62-
Properties merge(const Properties& Other) const {
62+
Properties merge(const Properties &Other) const {
6363
Properties Res;
64-
Res.HasESIMD = HasESIMD == Other.HasESIMD ? HasESIMD : SyclEsimdSplitStatus::SYCL_AND_ESIMD;
64+
Res.HasESIMD = HasESIMD == Other.HasESIMD
65+
? HasESIMD
66+
: SyclEsimdSplitStatus::SYCL_AND_ESIMD;
6567
Res.UsesDoubleGRF = UsesDoubleGRF || Other.UsesDoubleGRF;
6668
// Scope remains global
6769
return Res;
@@ -80,9 +82,13 @@ struct EntryPointGroup {
8082
: GroupId(GroupId), Functions(std::move(Functions)), Props(Props) {}
8183

8284
// Tells if this group has only ESIMD entry points (based on GroupId).
83-
bool isEsimd() const { return Props.HasESIMD == SyclEsimdSplitStatus::ESIMD_ONLY; }
85+
bool isEsimd() const {
86+
return Props.HasESIMD == SyclEsimdSplitStatus::ESIMD_ONLY;
87+
}
8488
// Tells if this group has only SYCL entry points (based on GroupId).
85-
bool isSycl() const { return Props.HasESIMD == SyclEsimdSplitStatus::SYCL_ONLY; }
89+
bool isSycl() const {
90+
return Props.HasESIMD == SyclEsimdSplitStatus::SYCL_ONLY;
91+
}
8692
// Tells if some entry points use double GRF mode.
8793
bool isDoubleGRF() const { return Props.UsesDoubleGRF; }
8894

@@ -121,7 +127,7 @@ class ModuleDesc {
121127
rebuildEntryPoints(Names);
122128
}
123129

124-
void assignMergedProperties(const ModuleDesc& MD1, const ModuleDesc& MD2);
130+
void assignMergedProperties(const ModuleDesc &MD1, const ModuleDesc &MD2);
125131

126132
bool isESIMD() const { return EntryPoints.isEsimd(); }
127133
bool isSYCL() const { return EntryPoints.isSycl(); }

llvm/tools/sycl-post-link/Support.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ inline void error(const Twine &Msg) {
3737
exit(1);
3838
}
3939

40-
inline void warning(const Twine& Msg) {
40+
inline void warning(const Twine &Msg) {
4141
errs() << "sycl-post-link WARNING: " << Msg << '\n';
4242
}
4343

0 commit comments

Comments
 (0)