Skip to content

Commit 42c1b89

Browse files
committed
[NFC][LLVM][Coroutines] Namespace related code cleanup
1 parent ab71b77 commit 42c1b89

File tree

7 files changed

+26
-53
lines changed

7 files changed

+26
-53
lines changed

llvm/include/llvm/Transforms/Coroutines/MaterializationUtils.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
#ifndef LLVM_TRANSFORMS_COROUTINES_MATERIALIZATIONUTILS_H
1313
#define LLVM_TRANSFORMS_COROUTINES_MATERIALIZATIONUTILS_H
1414

15-
namespace llvm {
16-
17-
namespace coro {
15+
namespace llvm::coro {
1816

1917
// True if I is trivially rematerialzable, e.g. InsertElementInst
2018
LLVM_ABI bool isTriviallyMaterializable(Instruction &I);
@@ -24,8 +22,6 @@ LLVM_ABI void
2422
doRematerializations(Function &F, SuspendCrossingInfo &Checker,
2523
std::function<bool(Instruction &)> IsMaterializable);
2624

27-
} // namespace coro
28-
29-
} // namespace llvm
25+
} // namespace llvm::coro
3026

3127
#endif // LLVM_TRANSFORMS_COROUTINES_MATERIALIZATIONUTILS_H

llvm/include/llvm/Transforms/Coroutines/SpillUtils.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313
#ifndef LLVM_TRANSFORMS_COROUTINES_SPILLINGINFO_H
1414
#define LLVM_TRANSFORMS_COROUTINES_SPILLINGINFO_H
1515

16-
namespace llvm {
17-
18-
namespace coro {
16+
namespace llvm::coro {
1917

2018
using SpillInfo = SmallMapVector<Value *, SmallVector<Instruction *, 2>, 8>;
2119

@@ -38,6 +36,7 @@ void collectSpillsAndAllocasFromInsts(
3836
SmallVector<CoroAllocaAllocInst *, 4> &LocalAllocas, Function &F,
3937
const SuspendCrossingInfo &Checker, const DominatorTree &DT,
4038
const coro::Shape &Shape);
39+
4140
void collectSpillsFromDbgInfo(SpillInfo &Spills, Function &F,
4241
const SuspendCrossingInfo &Checker);
4342

@@ -52,8 +51,6 @@ void sinkSpillUsesAfterCoroBegin(const DominatorTree &DT,
5251
BasicBlock::iterator getSpillInsertionPt(const coro::Shape &, Value *Def,
5352
const DominatorTree &DT);
5453

55-
} // namespace coro
56-
57-
} // namespace llvm
54+
} // namespace llvm::coro
5855

5956
#endif // LLVM_TRANSFORMS_COROUTINES_SPILLINGINFO_H

llvm/lib/Transforms/Coroutines/CoroCloner.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//===----------------------------------------------------------------------===//
12
//
23
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
34
// See https://llvm.org/LICENSE.txt for license information.
@@ -19,9 +20,7 @@
1920
#include "llvm/Transforms/Coroutines/CoroInstr.h"
2021
#include "llvm/Transforms/Utils/ValueMapper.h"
2122

22-
namespace llvm {
23-
24-
namespace coro {
23+
namespace llvm::coro {
2524

2625
enum class CloneKind {
2726
/// The shared resume function for a switch lowering.
@@ -149,8 +148,6 @@ class SwitchCloner : public BaseCloner {
149148
}
150149
};
151150

152-
} // end namespace coro
153-
154-
} // end namespace llvm
151+
} // end namespace llvm::coro
155152

156153
#endif // LLVM_LIB_TRANSFORMS_COROUTINES_COROCLONER_H

llvm/lib/Transforms/Coroutines/CoroEarly.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Lowerer : public coro::LowererBase {
3838
AnyResumeFnPtrTy(PointerType::getUnqual(Context)) {}
3939
void lowerEarlyIntrinsics(Function &F);
4040
};
41-
}
41+
} // namespace
4242

4343
// Replace a direct call to coro.resume or coro.destroy with an indirect call to
4444
// an address returned by coro.subfn.addr intrinsic. This is done so that

llvm/lib/Transforms/Coroutines/CoroInternal.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@
1616
#include "llvm/Transforms/Coroutines/CoroInstr.h"
1717
#include "llvm/Transforms/Coroutines/CoroShape.h"
1818

19-
namespace llvm {
20-
21-
class CallGraph;
22-
23-
namespace coro {
19+
namespace llvm::coro {
2420

2521
bool isSuspendBlock(BasicBlock *BB);
2622
bool declaresAnyIntrinsic(const Module &M);
@@ -61,7 +57,6 @@ void normalizeCoroutine(Function &F, coro::Shape &Shape,
6157
CallInst *createMustTailCall(DebugLoc Loc, Function *MustTailCallFn,
6258
TargetTransformInfo &TTI,
6359
ArrayRef<Value *> Arguments, IRBuilder<> &);
64-
} // End namespace coro.
65-
} // End namespace llvm
60+
} // End namespace llvm::coro
6661

6762
#endif

llvm/lib/Transforms/Coroutines/MaterializationUtils.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,7 @@ struct RematGraph {
137137

138138
} // namespace
139139

140-
namespace llvm {
141-
template <> struct GraphTraits<RematGraph *> {
140+
template <> struct llvm::GraphTraits<RematGraph *> {
142141
using NodeRef = RematGraph::RematNode *;
143142
using ChildIteratorType = RematGraph::RematNode **;
144143

@@ -149,8 +148,6 @@ template <> struct GraphTraits<RematGraph *> {
149148
static ChildIteratorType child_end(NodeRef N) { return N->Operands.end(); }
150149
};
151150

152-
} // end namespace llvm
153-
154151
// For each instruction identified as materializable across the suspend point,
155152
// and its associated DAG of other rematerializable instructions,
156153
// recreate the DAG of instructions after the suspend point.

llvm/lib/Transforms/Coroutines/SpillUtils.cpp

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,8 @@
1616
#include "llvm/IR/InstIterator.h"
1717
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
1818

19-
namespace llvm {
20-
21-
namespace coro {
22-
23-
namespace {
19+
using namespace llvm;
20+
using namespace llvm::coro;
2421

2522
typedef SmallPtrSet<BasicBlock *, 8> VisitedBlocksSet;
2623

@@ -71,7 +68,7 @@ static bool isLocalAlloca(CoroAllocaAllocInst *AI) {
7168
/// This happens during the all-instructions iteration, so it must not
7269
/// delete the call.
7370
static Instruction *
74-
lowerNonLocalAlloca(CoroAllocaAllocInst *AI, const coro::Shape &Shape,
71+
lowerNonLocalAlloca(CoroAllocaAllocInst *AI, const Shape &Shape,
7572
SmallVectorImpl<Instruction *> &DeadInsts) {
7673
IRBuilder<> Builder(AI);
7774
auto Alloc = Shape.emitAlloc(Builder, AI->getSize(), nullptr);
@@ -450,18 +447,16 @@ static void collectFrameAlloca(AllocaInst *AI, const coro::Shape &Shape,
450447
Visitor.getMayWriteBeforeCoroBegin());
451448
}
452449

453-
} // namespace
454-
455-
void collectSpillsFromArgs(SpillInfo &Spills, Function &F,
456-
const SuspendCrossingInfo &Checker) {
450+
void coro::collectSpillsFromArgs(SpillInfo &Spills, Function &F,
451+
const SuspendCrossingInfo &Checker) {
457452
// Collect the spills for arguments and other not-materializable values.
458453
for (Argument &A : F.args())
459454
for (User *U : A.users())
460455
if (Checker.isDefinitionAcrossSuspend(A, U))
461456
Spills[&A].push_back(cast<Instruction>(U));
462457
}
463458

464-
void collectSpillsAndAllocasFromInsts(
459+
void coro::collectSpillsAndAllocasFromInsts(
465460
SpillInfo &Spills, SmallVector<AllocaInfo, 8> &Allocas,
466461
SmallVector<Instruction *, 4> &DeadInstructions,
467462
SmallVector<CoroAllocaAllocInst *, 4> &LocalAllocas, Function &F,
@@ -516,8 +511,8 @@ void collectSpillsAndAllocasFromInsts(
516511
}
517512
}
518513

519-
void collectSpillsFromDbgInfo(SpillInfo &Spills, Function &F,
520-
const SuspendCrossingInfo &Checker) {
514+
void coro::collectSpillsFromDbgInfo(SpillInfo &Spills, Function &F,
515+
const SuspendCrossingInfo &Checker) {
521516
// We don't want the layout of coroutine frame to be affected
522517
// by debug information. So we only choose to salvage dbg.values for
523518
// whose value is already in the frame.
@@ -535,10 +530,9 @@ void collectSpillsFromDbgInfo(SpillInfo &Spills, Function &F,
535530

536531
/// Async and Retcon{Once} conventions assume that all spill uses can be sunk
537532
/// after the coro.begin intrinsic.
538-
void sinkSpillUsesAfterCoroBegin(const DominatorTree &Dom,
539-
CoroBeginInst *CoroBegin,
540-
coro::SpillInfo &Spills,
541-
SmallVectorImpl<coro::AllocaInfo> &Allocas) {
533+
void coro::sinkSpillUsesAfterCoroBegin(
534+
const DominatorTree &Dom, CoroBeginInst *CoroBegin, coro::SpillInfo &Spills,
535+
SmallVectorImpl<coro::AllocaInfo> &Allocas) {
542536
SmallSetVector<Instruction *, 32> ToMove;
543537
SmallVector<Instruction *, 32> Worklist;
544538

@@ -582,8 +576,9 @@ void sinkSpillUsesAfterCoroBegin(const DominatorTree &Dom,
582576
Inst->moveBefore(InsertPt->getIterator());
583577
}
584578

585-
BasicBlock::iterator getSpillInsertionPt(const coro::Shape &Shape, Value *Def,
586-
const DominatorTree &DT) {
579+
BasicBlock::iterator coro::getSpillInsertionPt(const coro::Shape &Shape,
580+
Value *Def,
581+
const DominatorTree &DT) {
587582
BasicBlock::iterator InsertPt;
588583
if (auto *Arg = dyn_cast<Argument>(Def)) {
589584
// For arguments, we will place the store instruction right after
@@ -625,7 +620,3 @@ BasicBlock::iterator getSpillInsertionPt(const coro::Shape &Shape, Value *Def,
625620

626621
return InsertPt;
627622
}
628-
629-
} // End namespace coro.
630-
631-
} // End namespace llvm.

0 commit comments

Comments
 (0)