-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Add support for reading YAML legacy type info dump #19707
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
Conversation
@swift-ci Please test |
@swift-ci Please test source compatibility |
b7499b9
to
384d91a
Compare
@swift-ci Please smoke test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty much like what we talked about – my comments are all little detail things. I think you should have a more IRGen-ish person look it over too, though, like Arnold or John.
@@ -497,6 +497,9 @@ def enable_class_resilience : Flag<["-"], "enable-class-resilience">, | |||
def enable_resilience_bypass : Flag<["-"], "enable-resilience-bypass">, | |||
HelpText<"Completely bypass resilience when accessing types in resilient frameworks">; | |||
|
|||
def read_type_info_path_EQ : Joined<["-"], "read-type-info-path=">, | |||
HelpText<"Read legacy type layout from the given path">; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the majority of options use -foo blah
rather than -foo=blah
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was just so that when testing I can write -Xfrontend -read-type-info-path=foo
instead of -Xfrontend -read-type-info-path -Xfrontend foo
. But I think this flag is only temporary, since we'll want to use some other mechanism to find these file(s) eventually, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, probably we'll just look in the resource directory. The -Xfrontend motivation is reasonable but I figure you're going to be using the flag mostly in tests, right?
lib/Frontend/CompilerInvocation.cpp
Outdated
@@ -1023,6 +1023,11 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args, | |||
Opts.EnableResilienceBypass = true; | |||
} | |||
|
|||
if (const Arg *A = Args.getLastArg(OPT_read_type_info_path_EQ)) { | |||
StringRef path(A->getValue()); | |||
Opts.ReadTypeInfoPath = path; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need to do this in two steps.
lib/IRGen/GenType.cpp
Outdated
} | ||
|
||
Optional<YAMLTypeInfoNode> | ||
TypeConverter::getLegacyTypeInfo(NominalTypeDecl *decl) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: const
lib/IRGen/GenType.cpp
Outdated
bool error = readLegacyTypeInfo(path); | ||
if (error) { | ||
llvm::errs() << "Cannot read '" << path << "'\n"; | ||
abort(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use llvm::report_fatal_error
for a slightly better aborting experience. Long-term, we may need to emit a proper diagnostic.
lib/IRGen/GenType.cpp
Outdated
CompletelyFragile = true; | ||
LoweringMode = Mode::CompletelyFragile; | ||
|
||
auto path = IGM.IRGen.Opts.ReadTypeInfoPath; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: It'd be good to explicitly make this a StringRef, in case we need to change the option to a std::string
.
Alignment(node.Alignment), | ||
IsPOD, /* irrelevant */ | ||
IsBitwiseTakable, /* irrelevant */ | ||
IsFixedSize /* irrelevant */), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since they're irrelevant, it's probably best to provide the safest options, i.e. non-POD, non-bitwise-takable…but yes fixed-size.
lib/IRGen/GenType.cpp
Outdated
NumExtraInhabitants(node.NumExtraInhabitants) {} | ||
|
||
// TODO: Override more methods to prevent you from doing anything with this | ||
// TypeInfo? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like a good idea. Are there more than what you've already provided?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wrote this TODO before I added the ones I put in, so I'll remove it.
lib/IRGen/GenType.h
Outdated
@@ -60,9 +62,29 @@ namespace irgen { | |||
/// The helper class for generating types. | |||
class TypeConverter { | |||
public: | |||
static unsigned const NumLoweringModes = 3; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: can you put this after the Mode enum, to make it more likely we'll remember to update it?
384d91a
to
a433975
Compare
@rjmccall Want to take a quick look too? |
…AML file The YAML format is the same one produced by the -dump-type-info frontend mode. For now this is only enabled if the -read-type-info-path frontend flag is specified. Progress on <rdar://problem/17528739>.
a433975
to
87ec607
Compare
@swift-ci Please smoke test |
@swift-ci Please smoke test macOS |
Progress on rdar://problem/17528739.