Skip to content

[NFC] SIL: Renamed SpecifyTestInst. #71418

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/swift/SIL/ParseTestSpecification.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ struct Arguments {
struct UnparsedSpecification {
/// The string which specifies the test.
///
/// Not a StringRef because the TestSpecificationInst whose payload is of
/// Not a StringRef because the SpecifyTestInst whose payload is of
/// interest gets deleted.
std::string string;
/// The next non-debug instruction.
Expand Down
9 changes: 4 additions & 5 deletions include/swift/SIL/SILBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -1065,11 +1065,10 @@ class SILBuilder {
return createDebugValue(Loc, src, Var);
}

TestSpecificationInst *
createTestSpecificationInst(SILLocation Loc,
StringRef ArgumentsSpecification) {
return insert(TestSpecificationInst::create(
getSILDebugLocation(Loc), ArgumentsSpecification, getModule()));
SpecifyTestInst *createSpecifyTestInst(SILLocation Loc,
StringRef ArgumentsSpecification) {
return insert(SpecifyTestInst::create(getSILDebugLocation(Loc),
ArgumentsSpecification, getModule()));
}

UnownedCopyValueInst *createUnownedCopyValue(SILLocation Loc,
Expand Down
5 changes: 2 additions & 3 deletions include/swift/SIL/SILCloner.h
Original file line number Diff line number Diff line change
Expand Up @@ -3124,10 +3124,9 @@ void SILCloner<ImplClass>::visitIncrementProfilerCounterInst(
}

template <typename ImplClass>
void SILCloner<ImplClass>::visitTestSpecificationInst(
TestSpecificationInst *Inst) {
void SILCloner<ImplClass>::visitSpecifyTestInst(SpecifyTestInst *Inst) {
getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope()));
recordClonedInstruction(Inst, getBuilder().createTestSpecificationInst(
recordClonedInstruction(Inst, getBuilder().createSpecifyTestInst(
getOpLocation(Inst->getLoc()),
Inst->getArgumentsSpecification()));
}
Expand Down
11 changes: 5 additions & 6 deletions include/swift/SIL/SILInstruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -5309,22 +5309,21 @@ class DebugValueInst final
}
};

class TestSpecificationInst final
: public InstructionBase<SILInstructionKind::TestSpecificationInst,
class SpecifyTestInst final
: public InstructionBase<SILInstructionKind::SpecifyTestInst,
NonValueInstruction>,
private llvm::TrailingObjects<TestSpecificationInst, char> {
private llvm::TrailingObjects<SpecifyTestInst, char> {
friend TrailingObjects;
friend SILBuilder;

llvm::StringMap<SILValue> values;
unsigned ArgumentsSpecificationLength;

TestSpecificationInst(SILDebugLocation Loc,
unsigned ArgumentsSpecificationLength)
SpecifyTestInst(SILDebugLocation Loc, unsigned ArgumentsSpecificationLength)
: InstructionBase(Loc),
ArgumentsSpecificationLength(ArgumentsSpecificationLength) {}

static TestSpecificationInst *
static SpecifyTestInst *
create(SILDebugLocation Loc, StringRef argumentsSpecification, SILModule &M);

public:
Expand Down
2 changes: 1 addition & 1 deletion include/swift/SIL/SILNodes.def
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ NON_VALUE_INST(DebugValueInst, debug_value,
SILInstruction, None, DoesNotRelease)
NON_VALUE_INST(DebugStepInst, debug_step,
SILInstruction, MayHaveSideEffects, DoesNotRelease)
NON_VALUE_INST(TestSpecificationInst, specify_test,
NON_VALUE_INST(SpecifyTestInst, specify_test,
SILInstruction, None, DoesNotRelease)
#define NEVER_OR_SOMETIMES_LOADABLE_CHECKED_REF_STORAGE(Name, name, ...) \
NON_VALUE_INST(Store##Name##Inst, store_##name, \
Expand Down
2 changes: 1 addition & 1 deletion lib/IRGen/IRGenSIL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1440,7 +1440,7 @@ class IRGenSILFunction :
void visitLinearFunctionExtractInst(LinearFunctionExtractInst *i);
void visitDifferentiabilityWitnessFunctionInst(
DifferentiabilityWitnessFunctionInst *i);
void visitTestSpecificationInst(TestSpecificationInst *i) {
void visitSpecifyTestInst(SpecifyTestInst *i) {
llvm_unreachable("test-only instruction in Lowered SIL?!");
}

Expand Down
2 changes: 1 addition & 1 deletion lib/SIL/IR/OperandOwnership.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ SHOULD_NEVER_VISIT_INST(ReleaseValueAddr)
SHOULD_NEVER_VISIT_INST(StrongRelease)
SHOULD_NEVER_VISIT_INST(GetAsyncContinuation)
SHOULD_NEVER_VISIT_INST(IncrementProfilerCounter)
SHOULD_NEVER_VISIT_INST(TestSpecification)
SHOULD_NEVER_VISIT_INST(SpecifyTest)
SHOULD_NEVER_VISIT_INST(ScalarPackIndex)
SHOULD_NEVER_VISIT_INST(Vector)

Expand Down
10 changes: 5 additions & 5 deletions lib/SIL/IR/SILInstructions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -546,15 +546,15 @@ IncrementProfilerCounterInst *IncrementProfilerCounterInst::create(
return Inst;
}

TestSpecificationInst *
TestSpecificationInst::create(SILDebugLocation Loc,
StringRef ArgumentsSpecification, SILModule &M) {
SpecifyTestInst *SpecifyTestInst::create(SILDebugLocation Loc,
StringRef ArgumentsSpecification,
SILModule &M) {
auto ArgumentsSpecificationLength = ArgumentsSpecification.size();
auto Size = totalSizeToAlloc<char>(ArgumentsSpecificationLength);
auto Buffer = M.allocateInst(Size, alignof(TestSpecificationInst));
auto Buffer = M.allocateInst(Size, alignof(SpecifyTestInst));

auto *Inst =
::new (Buffer) TestSpecificationInst(Loc, ArgumentsSpecificationLength);
::new (Buffer) SpecifyTestInst(Loc, ArgumentsSpecificationLength);
std::uninitialized_copy(ArgumentsSpecification.begin(),
ArgumentsSpecification.end(),
Inst->getTrailingObjects<char>());
Expand Down
2 changes: 1 addition & 1 deletion lib/SIL/IR/SILPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2679,7 +2679,7 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
*this << getIDAndType(RI->getOperand());
}

void visitTestSpecificationInst(TestSpecificationInst *TSI) {
void visitSpecifyTestInst(SpecifyTestInst *TSI) {
*this << QuotedString(TSI->getArgumentsSpecification());
}

Expand Down
4 changes: 2 additions & 2 deletions lib/SIL/Parser/ParseSIL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3410,7 +3410,7 @@ bool SILParser::parseSpecificSILInstruction(SILBuilder &B,
ResultVal = B.createDebugStep(InstLoc);
break;

case SILInstructionKind::TestSpecificationInst: {
case SILInstructionKind::SpecifyTestInst: {
// Parse the specification string.
if (P.Tok.getKind() != tok::string_literal) {
P.diagnose(P.Tok, diag::expected_sil_specify_test_body);
Expand All @@ -3421,7 +3421,7 @@ bool SILParser::parseSpecificSILInstruction(SILBuilder &B,
auto ArgumentsSpecification =
P.Tok.getText().drop_front(numQuotes).drop_back(numQuotes).trim();
P.consumeToken(tok::string_literal);
auto *tsi = B.createTestSpecificationInst(InstLoc, ArgumentsSpecification);
auto *tsi = B.createSpecifyTestInst(InstLoc, ArgumentsSpecification);
SmallVector<StringRef, 4> components;
test::getTestSpecificationComponents(ArgumentsSpecification, components);
for (auto component : components) {
Expand Down
10 changes: 5 additions & 5 deletions lib/SIL/Parser/ParseTestSpecification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,20 @@ void findAndDeleteTraceValues(SILFunction *function,
bool isDeleteableTestInstruction(SILInstruction const *instruction) {
if (auto *dvi = dyn_cast<DebugValueInst>(instruction))
return dvi->hasTrace();
if (isa<TestSpecificationInst>(instruction))
if (isa<SpecifyTestInst>(instruction))
return true;
return false;
}

SILInstruction *findAnchorInstructionAfter(TestSpecificationInst *tsi) {
SILInstruction *findAnchorInstructionAfter(SpecifyTestInst *tsi) {
for (auto *instruction = tsi->getNextInstruction(); instruction;
instruction = instruction->getNextInstruction()) {
if (!isDeleteableTestInstruction(instruction))
return instruction;
}
// This can't happen because a TestSpecificationInst isn't a terminator itself
// This can't happen because a SpecifyTestInst isn't a terminator itself
// nor are any deleteable instructions.
llvm_unreachable("found no anchor after TestSpecificationInst!?");
llvm_unreachable("found no anchor after SpecifyTestInst!?");
}

// Helpers: Looking up subobjects by index
Expand Down Expand Up @@ -701,7 +701,7 @@ void swift::test::getTestSpecifications(
SmallVectorImpl<UnparsedSpecification> &specifications) {
for (auto &block : *function) {
for (SILInstruction &inst : block.deletableInstructions()) {
if (auto *tsi = dyn_cast<TestSpecificationInst>(&inst)) {
if (auto *tsi = dyn_cast<SpecifyTestInst>(&inst)) {
auto ref = tsi->getArgumentsSpecification();
auto *anchor = findAnchorInstructionAfter(tsi);
specifications.push_back(
Expand Down
2 changes: 1 addition & 1 deletion lib/SIL/Parser/SILParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class SILParser {

/// Data structures used to perform name lookup for local values.
llvm::StringMap<ValueBase *> LocalValues;
llvm::StringMap<llvm::SmallVector<TestSpecificationInst *>> TestSpecsWithRefs;
llvm::StringMap<llvm::SmallVector<SpecifyTestInst *>> TestSpecsWithRefs;
llvm::StringMap<SourceLoc> ForwardRefLocalValues;

Type performTypeResolution(TypeRepr *TyR, bool IsSILType,
Expand Down
2 changes: 1 addition & 1 deletion lib/SIL/Utils/InstructionUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ RuntimeEffect swift::getRuntimeEffect(SILInstruction *inst, SILType &impactType)
case SILInstructionKind::DebugValueInst:
// Ignore runtime calls of debug_value
return RuntimeEffect::NoEffect;
case SILInstructionKind::TestSpecificationInst:
case SILInstructionKind::SpecifyTestInst:
// Ignore runtime calls of test-only instructions
return RuntimeEffect::NoEffect;

Expand Down
2 changes: 1 addition & 1 deletion lib/SILOptimizer/Analysis/RegionAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2392,7 +2392,7 @@ CONSTANT_TRANSLATION(EndApplyInst, Ignored)
CONSTANT_TRANSLATION(AbortApplyInst, Ignored)
CONSTANT_TRANSLATION(DebugStepInst, Ignored)
CONSTANT_TRANSLATION(IncrementProfilerCounterInst, Ignored)
CONSTANT_TRANSLATION(TestSpecificationInst, Ignored)
CONSTANT_TRANSLATION(SpecifyTestInst, Ignored)

//===---
// Require
Expand Down
2 changes: 1 addition & 1 deletion lib/SILOptimizer/UtilityPasses/SerializeSILPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ static bool hasOpaqueArchetype(TypeExpansionContext context,
case SILInstructionKind::MarkFunctionEscapeInst:
case SILInstructionKind::DebugValueInst:
case SILInstructionKind::DebugStepInst:
case SILInstructionKind::TestSpecificationInst:
case SILInstructionKind::SpecifyTestInst:
#define NEVER_OR_SOMETIMES_LOADABLE_CHECKED_REF_STORAGE(Name, ...) \
case SILInstructionKind::Store##Name##Inst:
#include "swift/AST/ReferenceStorage.def"
Expand Down
2 changes: 1 addition & 1 deletion lib/SILOptimizer/Utils/SILInliner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ InlineCost swift::instructionInlineCost(SILInstruction &I) {
case SILInstructionKind::MarkUnresolvedReferenceBindingInst:
case SILInstructionKind::CopyableToMoveOnlyWrapperValueInst:
case SILInstructionKind::MoveOnlyWrapperToCopyableValueInst:
case SILInstructionKind::TestSpecificationInst:
case SILInstructionKind::SpecifyTestInst:
case SILInstructionKind::MoveOnlyWrapperToCopyableAddrInst:
case SILInstructionKind::CopyableToMoveOnlyWrapperAddrInst:
case SILInstructionKind::MoveOnlyWrapperToCopyableBoxInst:
Expand Down
2 changes: 1 addition & 1 deletion lib/Serialization/DeserializeSIL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1334,7 +1334,7 @@ bool SILDeserializer::readSILInstruction(SILFunction *Fn,
switch (OpCode) {
case SILInstructionKind::DebugValueInst:
case SILInstructionKind::DebugStepInst:
case SILInstructionKind::TestSpecificationInst:
case SILInstructionKind::SpecifyTestInst:
case SILInstructionKind::AllocPackMetadataInst:
case SILInstructionKind::DeallocPackMetadataInst:
llvm_unreachable("not supported");
Expand Down
2 changes: 1 addition & 1 deletion lib/Serialization/SerializeSIL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,7 @@ void SILSerializer::writeSILInstruction(const SILInstruction &SI) {
// sense to write those instructions at all.
// TODO: decide if we want to serialize those instructions.
return;
case SILInstructionKind::TestSpecificationInst:
case SILInstructionKind::SpecifyTestInst:
// Instruction exists only for tests. Ignore it.
return;
case SILInstructionKind::AllocPackMetadataInst:
Expand Down