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
Add parser for textual ir #126
Conversation
There seems to be a weird bug where occasionally an SSA value is just not emitted. It can be seen in when running
In the last call operation, After some debugging, I found that If we want to round-trip IR through text, we have two options to fix this:
Option 1 is certainly more robust, but since values not being in blocks kinda breaks |
@HMPerson1 This looks great! I'll be trying this out today and merging it 👍 For register state, I'd like an additional line at the beginning of every function to "define" registers, much like declaring variables in source languages. This can be parsed to generate the register state later on. One thing I'd like to see are a few testcases, nothing too complicated -- just something that takes handwritten IR, generates the ssa structure and then assertions to check the lifting is correct. |
I've added some test cases. For register state, I already changed Also, could you comment on this problem? |
@HMPerson1 The question is, why is %16 not a part of the block? Does it belong to some other block? Did you look into this? If not, that needs some investigation. |
It looks like it happens in constant propagation, in let new_node = if w == 64 {
const_node
} else {
let address = self.g.address(*k).unwrap_or_else(..);
let opcode = MOpcode::OpNarrow(w as u16);
let new_node = self.g.insert_op(opcode, ndata.vt, None).unwrap_or_else(..);
self.g.set_address(new_node, address);
self.g.op_use(new_node, 0, const_node);
new_node
};
self.g.replace_value(*k, new_node); If I replace |
@@ -363,86 +373,59 @@ impl IRWriter { | |||
let line = match ssa.g[node] { | |||
NodeData::Op(ref opcode, vt) => { | |||
if let MOpcode::OpConst(_) = *opcode { | |||
radeco_err!("found const"); |
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.
why error?
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.
There shouldn't be any const nodes in inorder_walk
since all the const nodes should be in a separate table and not part of any particular block.
Do you think it might be better as radeco_warn
instead?
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.
No, then is ok. Sorry, oversaw that.
Also made some changes to `ir_writer` so that the SSA can be round-tripped. `minidec` also now checks that `ir_reader` can correctly read back whatever `ir_writer` wrote.
`remove_value` will unconditionally remove all edges adjacent to the given node and then remove it, when really we just want to remove the selector edge.
b27cdb8
to
64a16e4
Compare
@HMPerson1 How close is this to be merged? Most of the PR lgtm, if this can be merged, I'll give it another pass and merge it in. |
I think it's done now. Would you prefer a merge to fix the conflicts or a rebase? |
Either one is fine, rebase could be preferable. |
Great! SGTM, merging this in :) |
👍
… On 17 Mar 2018, at 00:08, Sushant Dinesh ***@***.***> wrote:
Great! SGTM, meaning this in :)
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Currently, it can roundtrip all the information that was already saved by
ir_writer
. There's probably still some information that is lost in the process (register state?) but I'm not sure what.Will fix #117 when done.