Skip to content

Commit 44cd8d7

Browse files
committed
SIL: remove some const from decl arguments in SILBasicBlock and SILArgument APIs
It's not needed and would just introduce some const_casts.
1 parent c251cd8 commit 44cd8d7

File tree

5 files changed

+24
-24
lines changed

5 files changed

+24
-24
lines changed

include/swift/SIL/SILArgument.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,20 @@ class SILArgument : public ValueBase {
5656
friend class SILBasicBlock;
5757

5858
SILBasicBlock *parentBlock;
59-
const ValueDecl *decl;
59+
ValueDecl *decl;
6060
USE_SHARED_UINT8;
6161

6262
protected:
6363
SILArgument(ValueKind subClassKind, SILBasicBlock *inputParentBlock,
6464
SILType type, ValueOwnershipKind ownershipKind,
65-
const ValueDecl *inputDecl = nullptr, bool reborrow = false,
65+
ValueDecl *inputDecl = nullptr, bool reborrow = false,
6666
bool pointerEscape = false);
6767

6868
// A special constructor, only intended for use in
6969
// SILBasicBlock::replacePHIArg and replaceFunctionArg.
7070
explicit SILArgument(ValueKind subClassKind, SILType type,
7171
ValueOwnershipKind ownershipKind,
72-
const ValueDecl *inputDecl = nullptr,
72+
ValueDecl *inputDecl = nullptr,
7373
bool reborrow = false, bool pointerEscape = false)
7474
: ValueBase(subClassKind, type), parentBlock(nullptr), decl(inputDecl) {
7575
sharedUInt8().SILArgument.valueOwnershipKind = uint8_t(ownershipKind);
@@ -137,7 +137,7 @@ class SILArgument : public ValueBase {
137137

138138
SILModule &getModule() const;
139139

140-
const ValueDecl *getDecl() const { return decl; }
140+
ValueDecl *getDecl() const { return decl; }
141141

142142
static bool classof(const SILInstruction *) = delete;
143143
static bool classof(const SILUndef *) = delete;
@@ -246,15 +246,15 @@ class SILPhiArgument : public SILArgument {
246246

247247
SILPhiArgument(SILBasicBlock *parentBlock, SILType type,
248248
ValueOwnershipKind ownershipKind,
249-
const ValueDecl *decl = nullptr, bool isReborrow = false,
249+
ValueDecl *decl = nullptr, bool isReborrow = false,
250250
bool hasPointerEscape = false)
251251
: SILArgument(ValueKind::SILPhiArgument, parentBlock, type, ownershipKind,
252252
decl, isReborrow, hasPointerEscape) {}
253253

254254
// A special constructor, only intended for use in
255255
// SILBasicBlock::replacePHIArg.
256256
explicit SILPhiArgument(SILType type, ValueOwnershipKind ownershipKind,
257-
const ValueDecl *decl = nullptr,
257+
ValueDecl *decl = nullptr,
258258
bool isReborrow = false,
259259
bool hasPointerEscape = false)
260260
: SILArgument(ValueKind::SILPhiArgument, type, ownershipKind, decl,
@@ -363,7 +363,7 @@ class SILFunctionArgument : public SILArgument {
363363

364364
SILFunctionArgument(
365365
SILBasicBlock *parentBlock, SILType type,
366-
ValueOwnershipKind ownershipKind, const ValueDecl *decl = nullptr,
366+
ValueOwnershipKind ownershipKind, ValueDecl *decl = nullptr,
367367
bool isNoImplicitCopy = false,
368368
LifetimeAnnotation lifetimeAnnotation = LifetimeAnnotation::None,
369369
bool isCapture = false, bool isParameterPack = false)
@@ -378,7 +378,7 @@ class SILFunctionArgument : public SILArgument {
378378
// A special constructor, only intended for use in
379379
// SILBasicBlock::replaceFunctionArg.
380380
explicit SILFunctionArgument(SILType type, ValueOwnershipKind ownershipKind,
381-
const ValueDecl *decl = nullptr)
381+
ValueDecl *decl = nullptr)
382382
: SILArgument(ValueKind::SILFunctionArgument, type, ownershipKind, decl) {
383383
}
384384

include/swift/SIL/SILBasicBlock.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -376,18 +376,18 @@ public SwiftObjectHeader {
376376
/// Allocate a new argument of type \p Ty and append it to the argument
377377
/// list. Optionally you can pass in a value decl parameter.
378378
SILFunctionArgument *createFunctionArgument(SILType Ty,
379-
const ValueDecl *D = nullptr,
379+
ValueDecl *D = nullptr,
380380
bool disableEntryBlockVerification = false);
381381

382382
SILFunctionArgument *insertFunctionArgument(unsigned AtArgPos, SILType Ty,
383383
ValueOwnershipKind OwnershipKind,
384-
const ValueDecl *D = nullptr);
384+
ValueDecl *D = nullptr);
385385

386386
/// Replace the \p{i}th Function arg with a new Function arg with SILType \p
387387
/// Ty and ValueDecl \p D.
388388
SILFunctionArgument *replaceFunctionArgument(unsigned i, SILType Ty,
389389
ValueOwnershipKind Kind,
390-
const ValueDecl *D = nullptr);
390+
ValueDecl *D = nullptr);
391391

392392
/// Replace the \p{i}th BB arg with a new BBArg with SILType \p Ty and
393393
/// ValueDecl \p D.
@@ -397,29 +397,29 @@ public SwiftObjectHeader {
397397
/// replacePhiArgumentAndRAUW.
398398
SILPhiArgument *replacePhiArgument(unsigned i, SILType type,
399399
ValueOwnershipKind kind,
400-
const ValueDecl *decl = nullptr,
400+
ValueDecl *decl = nullptr,
401401
bool isReborrow = false,
402402
bool isEscaping = false);
403403

404404
/// Replace phi argument \p i and RAUW all uses.
405405
SILPhiArgument *replacePhiArgumentAndReplaceAllUses(
406406
unsigned i, SILType type, ValueOwnershipKind kind,
407-
const ValueDecl *decl = nullptr, bool isReborrow = false,
407+
ValueDecl *decl = nullptr, bool isReborrow = false,
408408
bool isEscaping = false);
409409

410410
/// Allocate a new argument of type \p Ty and append it to the argument
411411
/// list. Optionally you can pass in a value decl parameter, reborrow flag and
412412
/// escaping flag.
413413
SILPhiArgument *createPhiArgument(SILType Ty, ValueOwnershipKind Kind,
414-
const ValueDecl *D = nullptr,
414+
ValueDecl *D = nullptr,
415415
bool isReborrow = false,
416416
bool isEscaping = false);
417417

418418
/// Insert a new SILPhiArgument with type \p Ty and \p Decl at position \p
419419
/// AtArgPos.
420420
SILPhiArgument *insertPhiArgument(unsigned AtArgPos, SILType Ty,
421421
ValueOwnershipKind Kind,
422-
const ValueDecl *D = nullptr,
422+
ValueDecl *D = nullptr,
423423
bool isReborrow = false,
424424
bool isEscaping = false);
425425

lib/SIL/IR/SILArgument.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ using namespace swift;
2929
SILArgument::SILArgument(ValueKind subClassKind,
3030
SILBasicBlock *inputParentBlock, SILType type,
3131
ValueOwnershipKind ownershipKind,
32-
const ValueDecl *inputDecl, bool reborrow,
32+
ValueDecl *inputDecl, bool reborrow,
3333
bool pointerEscape)
3434
: ValueBase(subClassKind, type), parentBlock(inputParentBlock),
3535
decl(inputDecl) {

lib/SIL/IR/SILBasicBlock.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ void SILBasicBlock::moveArgumentList(SILBasicBlock *from) {
178178
}
179179

180180
SILFunctionArgument *
181-
SILBasicBlock::createFunctionArgument(SILType Ty, const ValueDecl *D,
181+
SILBasicBlock::createFunctionArgument(SILType Ty, ValueDecl *D,
182182
bool disableEntryBlockVerification) {
183183
assert((disableEntryBlockVerification || isEntry()) &&
184184
"Function Arguments can only be in the entry block");
@@ -192,7 +192,7 @@ SILBasicBlock::createFunctionArgument(SILType Ty, const ValueDecl *D,
192192
SILFunctionArgument *SILBasicBlock::insertFunctionArgument(unsigned AtArgPos,
193193
SILType Ty,
194194
ValueOwnershipKind OwnershipKind,
195-
const ValueDecl *D) {
195+
ValueDecl *D) {
196196
assert(isEntry() && "Function Arguments can only be in the entry block");
197197
auto *arg = new (getModule()) SILFunctionArgument(Ty, OwnershipKind, D);
198198
arg->parentBlock = this;
@@ -201,7 +201,7 @@ SILFunctionArgument *SILBasicBlock::insertFunctionArgument(unsigned AtArgPos,
201201
}
202202

203203
SILFunctionArgument *SILBasicBlock::replaceFunctionArgument(
204-
unsigned i, SILType Ty, ValueOwnershipKind Kind, const ValueDecl *D) {
204+
unsigned i, SILType Ty, ValueOwnershipKind Kind, ValueDecl *D) {
205205
assert(isEntry() && "Function Arguments can only be in the entry block");
206206

207207
SILFunction *F = getParent();
@@ -226,7 +226,7 @@ SILFunctionArgument *SILBasicBlock::replaceFunctionArgument(
226226
/// ValueDecl D).
227227
SILPhiArgument *SILBasicBlock::replacePhiArgument(unsigned i, SILType Ty,
228228
ValueOwnershipKind Kind,
229-
const ValueDecl *D,
229+
ValueDecl *D,
230230
bool isReborrow,
231231
bool isEscaping) {
232232
assert(!isEntry() && "PHI Arguments can not be in the entry block");
@@ -250,7 +250,7 @@ SILPhiArgument *SILBasicBlock::replacePhiArgument(unsigned i, SILType Ty,
250250
}
251251

252252
SILPhiArgument *SILBasicBlock::replacePhiArgumentAndReplaceAllUses(
253-
unsigned i, SILType ty, ValueOwnershipKind kind, const ValueDecl *d,
253+
unsigned i, SILType ty, ValueOwnershipKind kind, ValueDecl *d,
254254
bool isReborrow, bool isEscaping) {
255255
// Put in an undef placeholder before we do the replacement since
256256
// replacePhiArgument() expects the replaced argument to not have
@@ -277,7 +277,7 @@ SILPhiArgument *SILBasicBlock::replacePhiArgumentAndReplaceAllUses(
277277

278278
SILPhiArgument *SILBasicBlock::createPhiArgument(SILType Ty,
279279
ValueOwnershipKind Kind,
280-
const ValueDecl *D,
280+
ValueDecl *D,
281281
bool isReborrow,
282282
bool isEscaping) {
283283
assert(!isEntry() && "PHI Arguments can not be in the entry block");
@@ -289,7 +289,7 @@ SILPhiArgument *SILBasicBlock::createPhiArgument(SILType Ty,
289289

290290
SILPhiArgument *SILBasicBlock::insertPhiArgument(unsigned AtArgPos, SILType Ty,
291291
ValueOwnershipKind Kind,
292-
const ValueDecl *D,
292+
ValueDecl *D,
293293
bool isReborrow,
294294
bool isEscaping) {
295295
assert(!isEntry() && "PHI Arguments can not be in the entry block");

lib/SILOptimizer/FunctionSignatureTransforms/FunctionSignatureOpts.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ struct ArgumentDescriptor {
4646
unsigned Index;
4747

4848
/// The original decl of this Argument.
49-
const ValueDecl *Decl;
49+
ValueDecl *Decl;
5050

5151
/// Was this parameter originally dead?
5252
bool IsEntirelyDead;

0 commit comments

Comments
 (0)