Skip to content

Conversation

dave-bartolomeo
Copy link
Contributor

This PR fixes a bunch of IR sanity test failures in ChakraCore due to lack of support for ConditionDeclExpr, which is used when the condition of an if or while statement declares a variable.

The first commit refactors the IR translation for variable declarations in a way that prepares it to be reused for ConditionDeclExpr, incorporating a change from @rdmarsh2's Chi PR (#474) to add an Uninitialized instruction to "initialize" any variable that is going to be truly initialized one field or element at a time.

The second commit adds IR translation for ConditionDeclExpr, fixing several existing library bugs around ConditionDeclExpr along the way.

This commit inserts an `Uninitialized` instruction to "initialize" a local variable when that variable is initialized with an initializer list. This ensures that there is always a definition of the whole variable before any read or write to part of that variable.

This change appears in a different form in @rdmarsh2's Chi node PR, but I needed to refactor the initialization code anyway to handle ConditionDeclExpr.
Also fixes several places in the library that weren't handling `ConditionalDeclExpr`  correctly.
@dave-bartolomeo dave-bartolomeo requested a review from a team as a code owner November 21, 2018 08:21
Copy link
Contributor

@jbj jbj left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM

# 519| v0_38(void) = ReturnVoid :
# 519| v0_39(void) = UnmodeledUse : mu*
# 519| v0_40(void) = ExitFunction :
# 520| mu0_7(int[3]) = Uninitialized : r0_6
Copy link
Contributor

Choose a reason for hiding this comment

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

Are there any tests that show the Uninitialized instruction being consumed by another instruction? For example, here it produces mu0_7, but I see no instruction with mu0_7 as an operand.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not without the Chi node PR. I only made this change in this PR because the primary purpose of my PR, the ConditionDeclExpr work, required refactoring the same code that @rdmarsh2 modified in his Chi PR. Making this change here saved him the trouble of a hard-to-resolve merge conflict.

@jbj jbj merged commit 70e9d11 into github:master Nov 22, 2018
jbj added a commit to jbj/ql that referenced this pull request Nov 22, 2018
This test was failing due to a semantic merge conflict between github#509,
which added `UninitializedInstruction`, and github#517, which added new test
code that would get `UninitializedInstruction`s in it after merging with github#509.
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.

2 participants