Skip to content

Conversation

@davezarzycki
Copy link
Contributor

No description provided.

@davezarzycki davezarzycki requested review from eeckstein and gottesmm May 4, 2020 11:06
@davezarzycki
Copy link
Contributor Author

@swift-ci please smoke test

@davezarzycki
Copy link
Contributor Author

Ping. Hi @gottesmm and @eeckstein – This seems like a simple QoI fix, right? Am I missing anything?

Copy link
Contributor

@eeckstein eeckstein left a comment

Choose a reason for hiding this comment

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

This builtin needs to be supported in IRGen's emitConstantValue, too.
Can you add an "-emit-ir" test as well (you can do it in the same test file)?

@davezarzycki
Copy link
Contributor Author

Hi @eeckstein – I feel like I'm missing something. Why does emitConstantValue need to special case BuiltinValueKind::ZeroInitializer when the code gen for this builtin already emits a constant? I ask because I'm not observing any behavioral differences with your suggestion.

@davezarzycki
Copy link
Contributor Author

I did some sanity checks. The code you requested is definitely being called but it's not making an observable difference in the IR with the simple test I provided. Do I need some non-trivial Swift/SIL to observe the change you requested?

@davezarzycki davezarzycki requested a review from rjmccall May 7, 2020 14:30
@eeckstein
Copy link
Contributor

Hm, don't you hit the

llvm_unreachable("unsupported builtin for constant expression");

?

@rjmccall
Copy link
Contributor

rjmccall commented May 7, 2020

I think the key question is whether this is actually emitted as a constant initializer. I don't know if changing this one SIL predicate is sufficient for that.

@davezarzycki
Copy link
Contributor Author

My mistake. I wasn't doing a proper A versus B comparison. Patch updated.

@swift-ci please smoke test

@davezarzycki
Copy link
Contributor Author

Updated CHECK to use a regular expression to account for macOS versus Linux differences.

@swift-ci please smoke test

@davezarzycki davezarzycki requested a review from eeckstein May 8, 2020 12:48
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a test for this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, is there a good arbitrary width constant test I can copy from?

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you fix the indentation here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm... I just ran the code through git clang-format and this was the sub-optimal result. I can either re‑indent all of the case statements to match clang style, or have this change match the rest of the case statements. What would you prefer?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't mind

@davezarzycki
Copy link
Contributor Author

I dropped support for arbitrary width integers for two reasons: 1) using Builtin.zeroInitializer() with Builtin.IntLiteral type would be strange and 2) making that work would require more builtins to be handled in SIL and IRGen's constant handling logic.

I also overrode git clang-format and made the new case statement match the neighboring case statements.

@swift-ci please smoke test

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a check here, which returns false if it's an arbitrary width integer?

@davezarzycki
Copy link
Contributor Author

Updated to have isValidStaticInitializerInst return false if the zero initializer has arbitrary width.

@swift-ci please smoke test

@davezarzycki
Copy link
Contributor Author

Replaced uses of AnyBuiltinIntegerType with BuiltinIntegerType to avoid arbitrary width problems.

@swift-ci please smoke test

@davezarzycki
Copy link
Contributor Author

Added float and vector support. What's left before a LGTM?

@swift-ci please smoke test

@rjmccall
Copy link
Contributor

Not supporting BuiltinIntegerLiteralType is appropriate since IIUC we want this builtin to guarantee a zero-bit representation, which is not a valid inhabitant of that type (there always has to be at least one word of data, to avoid that being a special case).

Copy link
Contributor

@eeckstein eeckstein left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM!

@davezarzycki davezarzycki merged commit 58d163b into swiftlang:master May 12, 2020
@davezarzycki davezarzycki deleted the pr31528 branch May 12, 2020 09:49
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