Skip to content

Conversation

@hamishknight
Copy link
Contributor

With an inverted pipeline, IRGen needs to be able to compute the linker directives itself, so sink it down such that it can be computed by the IRGenDescriptor.

@hamishknight hamishknight requested a review from nkcsgexi July 13, 2020 21:34
Copy link
Contributor

@nkcsgexi nkcsgexi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this isn't your bug, but I'm shocked we iterate over a StringSet here without sorting it. This cannot be correct in general.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I'm pretty sure you don't need to take the StringRefs here by reference since they're trivially copyable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this isn't your bug, but I'm shocked we iterate over a StringSet here without sorting it. This cannot be correct in general.

Ouch, good spot! Looks like we also do this in writeLdAddCFileIfNeeded. @nkcsgexi, should TBDGen return a vector of symbols instead of a set?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I'm pretty sure you don't need to take the StringRefs here by reference since they're trivially copyable.

It's a (StringRef, string length) pair, but yeah I guess & is a little overkill

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CodaFi is deterministics your concern here or do you have other concerns?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. This code builds globals into the generated LLVM module.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched to returning a vector, how does this look?

Instead of taking an out parameter, have it return
the set directly. Also coalesce the two overloads
into a single overload that takes a
`TBDGenDescriptor`.
With an inverted pipeline, IRGen needs to be able
to compute the linker directives itself, so sink
it down such that it can be computed by the
`IRGenDescriptor`.
A couple of clients are iterating over the result,
so switch to a vector to ensure we don't
accidentally introduce any non-determinism.
@hamishknight
Copy link
Contributor Author

swiftlang/llvm-project#1447

@swift-ci please test

hamishknight added a commit to swiftlang/llvm-project that referenced this pull request Jul 14, 2020
@hamishknight hamishknight merged commit 09bc359 into swiftlang:master Jul 14, 2020
@hamishknight hamishknight deleted the linked-in branch July 14, 2020 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants