Skip to content

[pull] swiftwasm from main #5521

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 25 commits into from
Jun 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b14c00d
Support required inits in @objcImpl
beccadax Jun 1, 2023
fdb00be
[docs] GettingStarted: Add a warning about spaces in the absolute path
Jun 8, 2023
b1e58cf
Update FAQ.md
natsuk4ze Jun 10, 2023
b46943f
Add syntax
natsuk4ze Jun 10, 2023
a446df3
Update docs/HowToGuides/FAQ.md
natsuk4ze Jun 12, 2023
ff50cca
Update FAQ.md
natsuk4ze Jun 13, 2023
7b2c3d2
Add syntax in FAQ.md
natsuk4ze Jun 13, 2023
dab1cb5
[cxx-interop] Simplify a `std::string` test
egorzhdan Jun 13, 2023
042aff2
[cxx-interop] Optimize CxxSet initialization from a Swift Sequence
egorzhdan Jun 13, 2023
58ff42a
[Runtime] Properly handle tuple types in layout string instantiation …
drexin Jun 13, 2023
5d401fb
Remove select_value SIL instruction
meg-gupta Jun 13, 2023
0d1095e
Merge pull request #66262 from beccadax/your-implementation-is-required
swift-ci Jun 13, 2023
19094e3
Merge pull request #66456 from simanerush/gettingstarted-spacewarning
xedin Jun 13, 2023
0ceff1b
Disable several Backtracing tests on Linux AArch64.
tshortli Jun 14, 2023
dc69f14
Merge pull request #66614 from tshortli/disable-backtracing-tests-lin…
tshortli Jun 14, 2023
01da1cb
Add warnings on top
natsuk4ze Jun 14, 2023
6a2f3c9
Merge pull request #66608 from meg-gupta/removeselectvalue
meg-gupta Jun 14, 2023
63808be
DefinitInitialization: convert begin_access instructions of initializ…
eeckstein Jun 13, 2023
5c5cd9f
DeadObjectElimination: ignore begin_access and end_access instructions
eeckstein Jun 13, 2023
79c1e94
Revert "Disable several Backtracing tests on Linux AArch64."
tshortli Jun 14, 2023
4a51ec1
Merge pull request #66617 from tshortli/revert-disable-backtracing-te…
tshortli Jun 14, 2023
5bddd51
Merge pull request #66601 from apple/egorzhdan/borrow-cxxset-init
egorzhdan Jun 14, 2023
2465d15
Merge pull request #66599 from apple/egorzhdan/simplify-std-string-test
egorzhdan Jun 14, 2023
4d99f01
Merge pull request #66538 from natsuk4ze/do-todo-of-faq
LucianoPAlmeida Jun 14, 2023
7cb1e0d
Merge pull request #66592 from eeckstein/access-optimizations
swift-ci Jun 14, 2023
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
48 changes: 46 additions & 2 deletions docs/HowToGuides/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,49 @@ git rebase --continue

### How do I clean up my git history?

TODO: Link to a beginner-friendly external resource, or (less preferably)
describe basic usage of rebase here.
Git's history can sometimes become cluttered with many small commits.
Fortunately, Git has a feature called `rebase` that allows you to clean up your commit history.
If you want to learn more,
[GitHub - About Git rebase](https://docs.github.com/en/get-started/using-git/about-git-rebase)
provides a comprehensive overview of `rebase`.

> **Warning**
We suggest considering to `rebase` only those commits that haven't been pushed to a public branch.
Rebasing existing commits would block merging because we don't allow force pushes to the repository.
If you need to tidy up commits that have already been pushed,
it's generally better to use `git revert` for the sake of avoid causing confusion for other developers.


Here's a small gist that goes through the basics on how to use it:

1. Begin an interactive rebase: Use `git rebase -i HEAD~N`, where `N` is the number of commits
from the latest one you want to edit. This will open a text editor,
listing the last `N` commits with the word "pick" next to each one.

```sh
git rebase -i HEAD~N
```

2. Edit the commits: Replace "pick" with the operation you want to perform on the commit:

- `reword`: Change the commit message.
- `edit`: Amend the commit.
- `squash`: Combine the commit with the previous one.
- `fixup`: Similar to `squash`, but discard this commit's log message.
- `drop`: Remove the commit.

3. Save and exit: After saving and closing the file, git will execute each operation.
If you selected `reword`, `edit`, or `squash`, git will pause and give you a chance
to alter the commit message or the commit itself.

```sh
git commit --amend
```

4. Continue the rebase: Once you're done with each commit, you can continue the rebase
using `git rebase --continue`. If you want to abort the rebase at any point,
you can use `git rebase --abort`.

```sh
git rebase --continue
```
8 changes: 5 additions & 3 deletions docs/HowToGuides/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ toolchain as a one-off, there are a couple of differences:
mkdir swift-project
cd swift-project
```

> **Warning**
> Make sure the absolute path to your `swift-project` directory **does not** contain spaces,
since that might cause issues during the build step.

2. Clone the sources:
- Via SSH (recommended):
If you plan on contributing regularly, cloning over SSH provides a better
Expand Down Expand Up @@ -121,9 +126,6 @@ toolchain as a one-off, there are a couple of differences:

- If `update-checkout` failed, double-check that the absolute path to your
working directory does not have non-ASCII characters.
- If `update-checkout` failed and the absolute path to your working directory
had spaces in it, please [file a bug report][Swift Issues] and change the path
to work around it.
- Before running `update-checkout`, double-check that `swift` is the only
repository inside the `swift-project` directory. Otherwise,
`update-checkout` may not clone the necessary dependencies.
Expand Down
41 changes: 0 additions & 41 deletions docs/SIL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3475,8 +3475,6 @@ A value ``%1`` is said to be *value-dependent* on a value ``%0`` if:
with ``tuple_extract``, ``struct_extract``, ``unchecked_enum_data``,
``select_enum``, or ``select_enum_addr``.

- ``%1`` is the result of ``select_value`` and ``%0`` is one of the cases.

- ``%1`` is a basic block parameter and ``%0`` is the corresponding
argument from a branch to that block.

Expand Down Expand Up @@ -7949,45 +7947,6 @@ block. If there is a ``default`` basic block, control is transferred to it if
the value does not match any of the ``case`` values. It is undefined behavior
if the value does not match any cases and no ``default`` branch is provided.

select_value
````````````
::

sil-instruction ::= 'select_value' sil-operand sil-select-value-case*
(',' 'default' sil-value)?
':' sil-type
sil-select-value-case ::= 'case' sil-value ':' sil-value


%n = select_value %0 : $U, \
case %c1: %r1, \
case %c2: %r2, /* ... */ \
default %r3 : $T

// $U must be a builtin type. Only integers types are supported currently.
// c1, c2, etc must be of type $U
// %r1, %r2, %r3, etc. must have type $T
// %n has type $T

Selects one of the "case" or "default" operands based on the case of a
value. This is equivalent to a trivial `switch_value`_ branch sequence::

entry:
switch_value %0 : $U, \
case %c1: bb1, \
case %c2: bb2, /* ... */ \
default bb_default
bb1:
br cont(%r1 : $T) // value for %c1
bb2:
br cont(%r2 : $T) // value for %c2
bb_default:
br cont(%r3 : $T) // value for default
cont(%n : $T):
// use argument %n

but turns the control flow dependency into a data flow dependency.

switch_enum
```````````
::
Expand Down
5 changes: 5 additions & 0 deletions include/swift/AST/DiagnosticsSema.def
Original file line number Diff line number Diff line change
Expand Up @@ -1709,6 +1709,11 @@ ERROR(objc_implementation_type_mismatch,none,
"header",
(DescriptiveDeclKind, ValueDecl *, Type, Type))

ERROR(objc_implementation_required_attr_mismatch,none,
"%0 %1 %select{should not|should}2 be 'required' to match %0 declared by "
"the header",
(DescriptiveDeclKind, ValueDecl *, bool))

ERROR(objc_implementation_wrong_objc_name,none,
"selector %0 for %1 %2 not found in header; did you mean %3?",
(ObjCSelector, DescriptiveDeclKind, ValueDecl *, ObjCSelector))
Expand Down
6 changes: 3 additions & 3 deletions include/swift/Runtime/Metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -666,9 +666,6 @@ void swift_initStructMetadataWithLayoutString(StructMetadata *self,
const uint8_t *fieldTags,
uint32_t *fieldOffsets);

SWIFT_RUNTIME_STDLIB_INTERNAL
size_t _swift_refCountBytesForMetatype(const Metadata *type);

enum LayoutStringFlags : uint64_t {
Empty = 0,
// TODO: Track other useful information tha can be used to optimize layout
Expand All @@ -688,6 +685,9 @@ inline LayoutStringFlags &operator|=(LayoutStringFlags &a, LayoutStringFlags b)
return a = (a | b);
}

SWIFT_RUNTIME_STDLIB_INTERNAL
size_t _swift_refCountBytesForMetatype(const Metadata *type);

SWIFT_RUNTIME_STDLIB_INTERNAL
void _swift_addRefCountStringForMetatype(uint8_t *layoutStr,
size_t &layoutStrOffset,
Expand Down
8 changes: 0 additions & 8 deletions include/swift/SIL/SILBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -1730,14 +1730,6 @@ class SILBuilder {
getModule(), CaseCounts, DefaultCount));
}

SelectValueInst *createSelectValue(
SILLocation Loc, SILValue Operand, SILType Ty, SILValue DefaultResult,
ArrayRef<std::pair<SILValue, SILValue>> CaseValuesAndResult) {
return insert(SelectValueInst::create(getSILDebugLocation(Loc), Operand, Ty,
DefaultResult, CaseValuesAndResult,
getModule()));
}

TupleExtractInst *createTupleExtract(SILLocation Loc, SILValue Operand,
unsigned FieldNo, SILType ResultTy) {
return createTupleExtract(Loc, Operand, FieldNo, ResultTy,
Expand Down
18 changes: 0 additions & 18 deletions include/swift/SIL/SILCloner.h
Original file line number Diff line number Diff line change
Expand Up @@ -3251,24 +3251,6 @@ SILCloner<ImplClass>::visitSelectEnumAddrInst(SelectEnumAddrInst *Inst) {
CaseResults));
}

template<typename ImplClass>
void
SILCloner<ImplClass>::visitSelectValueInst(SelectValueInst *Inst) {
SILValue DefaultResult;
if (Inst->hasDefault())
DefaultResult = getOpValue(Inst->getDefaultResult());
SmallVector<std::pair<SILValue, SILValue>, 8> CaseResults;
for (unsigned i = 0, e = Inst->getNumCases(); i != e; ++i)
CaseResults.push_back(std::make_pair(getOpValue(Inst->getCase(i).first),
getOpValue(Inst->getCase(i).second)));

getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope()));
recordClonedInstruction(
Inst, getBuilder().createSelectValue(
getOpLocation(Inst->getLoc()), getOpValue(Inst->getOperand()),
getOpType(Inst->getType()), DefaultResult, CaseResults));
}

template <typename ImplClass>
void SILCloner<ImplClass>::visitDynamicMethodBranchInst(
DynamicMethodBranchInst *Inst) {
Expand Down
49 changes: 2 additions & 47 deletions include/swift/SIL/SILInstruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -1392,7 +1392,6 @@ FirstArgOwnershipForwardingSingleValueInst::classof(SILInstructionKind kind) {
case SILInstructionKind::ObjectInst:
case SILInstructionKind::EnumInst:
case SILInstructionKind::UncheckedEnumDataInst:
case SILInstructionKind::SelectValueInst:
case SILInstructionKind::OpenExistentialRefInst:
case SILInstructionKind::InitExistentialRefInst:
case SILInstructionKind::MarkDependenceInst:
Expand Down Expand Up @@ -6659,8 +6658,8 @@ class UncheckedTakeEnumDataAddrInst
}
};

// Abstract base class of all select instructions like select_enum,
// select_value, etc. The template parameter represents a type of case values
// Abstract base class of all select instructions like select_enum.
// The template parameter represents a type of case values
// to be compared with the operand of a select instruction.
//
// Subclasses must provide tail allocated storage.
Expand Down Expand Up @@ -6878,50 +6877,6 @@ class SelectEnumAddrInst final
ProfileCounter DefaultCount);
};

/// Select on a value of a builtin integer type.
///
/// There is 'the' operand, followed by pairs of operands for each case,
/// followed by an optional default operand.
class SelectValueInst final
: public InstructionBaseWithTrailingOperands<
SILInstructionKind::SelectValueInst, SelectValueInst,
SelectInstBase<SelectValueInst, SILValue, SingleValueInstruction>> {
friend SILBuilder;

SelectValueInst(SILDebugLocation DebugLoc, SILValue Operand, SILType Type,
SILValue DefaultResult,
ArrayRef<SILValue> CaseValuesAndResults);

static SelectValueInst *
create(SILDebugLocation DebugLoc, SILValue Operand, SILType Type,
SILValue DefaultValue,
ArrayRef<std::pair<SILValue, SILValue>> CaseValues, SILModule &M);

public:
std::pair<SILValue, SILValue>
getCase(unsigned i) const {
auto cases = getAllOperands().slice(1);
return {cases[i*2].get(), cases[i*2+1].get()};
}

unsigned getNumCases() const {
// Ignore the first non-case operand.
auto count = getAllOperands().size() - 1;
// This implicitly ignore the optional default operand.
return count / 2;
}

bool hasDefault() const {
// If the operand count is even, then we have a default value.
return (getAllOperands().size() & 1) == 0;
}

SILValue getDefaultResult() const {
assert(hasDefault() && "doesn't have a default");
return getAllOperands().back().get();
}
};

/// MetatypeInst - Represents the production of an instance of a given metatype
/// named statically.
class MetatypeInst final
Expand Down
2 changes: 0 additions & 2 deletions include/swift/SIL/SILNodes.def
Original file line number Diff line number Diff line change
Expand Up @@ -609,8 +609,6 @@ ABSTRACT_VALUE_AND_INST(SingleValueInstruction, ValueBase, SILInstruction)
SingleValueInstruction, None, DoesNotRelease)
SINGLE_VALUE_INST(SelectEnumAddrInst, select_enum_addr,
SingleValueInstruction, MayRead, DoesNotRelease)
SINGLE_VALUE_INST(SelectValueInst, select_value,
SingleValueInstruction, None, DoesNotRelease)

// Protocol and Protocol Composition Types
SINGLE_VALUE_INST(InitExistentialAddrInst, init_existential_addr,
Expand Down
22 changes: 0 additions & 22 deletions lib/IRGen/IRGenSIL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1300,7 +1300,6 @@ class IRGenSILFunction :
void visitInitEnumDataAddrInst(InitEnumDataAddrInst *i);
void visitSelectEnumInst(SelectEnumInst *i);
void visitSelectEnumAddrInst(SelectEnumAddrInst *i);
void visitSelectValueInst(SelectValueInst *i);
void visitUncheckedEnumDataInst(UncheckedEnumDataInst *i);
void visitUncheckedTakeEnumDataAddrInst(UncheckedTakeEnumDataAddrInst *i);
void visitInjectEnumAddrInst(InjectEnumAddrInst *i);
Expand Down Expand Up @@ -4658,27 +4657,6 @@ void IRGenSILFunction::visitSelectEnumAddrInst(SelectEnumAddrInst *inst) {
// emitBBMapForSelectEnum set up a phi node to receive the result.
Builder.SetInsertPoint(contBB);
}

setLoweredValue(inst,
getLoweredValueForSelect(*this, result, inst));
}

void IRGenSILFunction::visitSelectValueInst(SelectValueInst *inst) {
Explosion value = getLoweredExplosion(inst->getOperand());

// Map the SIL dest bbs to their LLVM bbs.
SmallVector<std::pair<SILValue, llvm::BasicBlock*>, 4> dests;
llvm::BasicBlock *defaultDest;
Explosion result;
auto *contBB = emitBBMapForSelect(*this, result, dests, defaultDest, inst);

// Emit the dispatch.
emitSwitchValueDispatch(*this, inst->getOperand()->getType(), value, dests,
defaultDest);

// emitBBMapForSelectEnum set up a continuation block and phi nodes to
// receive the result.
Builder.SetInsertPoint(contBB);

setLoweredValue(inst,
getLoweredValueForSelect(*this, result, inst));
Expand Down
2 changes: 0 additions & 2 deletions lib/SIL/IR/OperandOwnership.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,6 @@ OPERAND_OWNERSHIP(TrivialUse, PointerToAddress)
OPERAND_OWNERSHIP(TrivialUse, ProjectBlockStorage)
OPERAND_OWNERSHIP(TrivialUse, RawPointerToRef)
OPERAND_OWNERSHIP(TrivialUse, SelectEnumAddr)
// select_value is only supported for integer types currently.
OPERAND_OWNERSHIP(TrivialUse, SelectValue)
OPERAND_OWNERSHIP(TrivialUse, StructElementAddr)
OPERAND_OWNERSHIP(TrivialUse, SwitchEnumAddr)
OPERAND_OWNERSHIP(TrivialUse, SwitchValue)
Expand Down
19 changes: 0 additions & 19 deletions lib/SIL/IR/SILInstruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -688,25 +688,6 @@ namespace {
return visitSelectEnumInstBase(RHS);
}

bool visitSelectValueInst(const SelectValueInst *RHS) {
// Check that the instructions match cases in the same order.
auto *X = cast<SelectValueInst>(LHS);

if (X->getNumCases() != RHS->getNumCases())
return false;
if (X->hasDefault() != RHS->hasDefault())
return false;

for (unsigned i = 0, e = X->getNumCases(); i < e; ++i) {
if (X->getCase(i).first != RHS->getCase(i).first)
return false;
if (X->getCase(i).second != RHS->getCase(i).second)
return false;
}

return true;
}

// Conversion instructions.
// All of these just return true as they have already had their
// operands and types checked
Expand Down
29 changes: 0 additions & 29 deletions lib/SIL/IR/SILInstructions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1975,35 +1975,6 @@ SwitchValueInst *SwitchValueInst::create(
return ::new (buf) SwitchValueInst(Loc, Operand, DefaultBB, Cases, BBs);
}

SelectValueInst::SelectValueInst(SILDebugLocation DebugLoc, SILValue Operand,
SILType Type, SILValue DefaultResult,
ArrayRef<SILValue> CaseValuesAndResults)
: InstructionBaseWithTrailingOperands(Operand, CaseValuesAndResults,
DebugLoc, Type) {}

SelectValueInst *
SelectValueInst::create(SILDebugLocation Loc, SILValue Operand, SILType Type,
SILValue DefaultResult,
ArrayRef<std::pair<SILValue, SILValue>> CaseValues,
SILModule &M) {
// Allocate enough room for the instruction with tail-allocated data for all
// the case values and the SILSuccessor arrays. There are `CaseBBs.size()`
// SILValues and `CaseBBs.size() + (DefaultBB ? 1 : 0)` successors.
SmallVector<SILValue, 8> CaseValuesAndResults;
for (auto pair : CaseValues) {
CaseValuesAndResults.push_back(pair.first);
CaseValuesAndResults.push_back(pair.second);
}

if ((bool)DefaultResult)
CaseValuesAndResults.push_back(DefaultResult);

auto Size = totalSizeToAlloc<swift::Operand>(CaseValuesAndResults.size() + 1);
auto Buf = M.allocateInst(Size, alignof(SelectValueInst));
return ::new (Buf)
SelectValueInst(Loc, Operand, Type, DefaultResult, CaseValuesAndResults);
}

template <typename SELECT_ENUM_INST>
SELECT_ENUM_INST *SelectEnumInstBase::createSelectEnum(
SILDebugLocation Loc, SILValue Operand, SILType Ty, SILValue DefaultValue,
Expand Down
Loading