The dismantle_for_statements pass in the transforms module converts ForStatement nodes into branches. Roughly speaking, it converts FOR I = 0 TO 10 STEP 2 (body) into I = 0 continue_label: (body) I = I + 2 IF I < 10 GOTO continue_label break_label: However, the code for the pass does this wrong; when trying to determine if the loop has terminated, it compares the index variable to the step size, not the upper bound. The following patch (to basepasses/transforms/statement_dismantlers.cpp) fixes this problem: --- nci/suif/suif2b/basepasses/transforms/statement_dismantlers.cpp.orig Fri Jun 8 16:31:05 2001 +++ nci/suif/suif2b/basepasses/transforms/statement_dismantlers.cpp Fri Jun 8 16:31:13 2001 @@ -415,7 +415,7 @@ create_binary_expression(body->get_suif_env(),type, compare_op, deep_suif_clone(index_expr), - deep_suif_clone(step)); + deep_suif_clone(upper)); replacement->append_statement(create_branch_statement(body->get_suif_env(),compare,continue_lab)); // end of loop Thanks, -- David Maze dmaze@mit.edu http://www.mit.edu/~dmaze/ "Theoretical politics is interesting. Politicking should be illegal." -- Abra Mitchell ------------------------------------------------------------------------ SUIF2 internally represents C strings as char arrays, which in turn are MultiValueBlocks. Strings with repeated characters, like "foo", are compressed with RepeatValueBlocks, so the string might represented as MultiValueBlock { 0: ExpressionValueBlock "f" 8: RepeatValueBlock(2) { ExpressionValueBlock "o" } 24: ExpressionValueBlock "\0" } The insert_struct_padding pass in the transforms module is implemented in nci/suif/suif2b/basepasses/transforms/padding.cpp. In the course of the pass, the Padding::rebuild_value_block() function is called. For array types, the code (around padding.cpp line 87) iterates through the values in the MultiValueBlock and builds up its own internal list of (offset, value). However, the code ignores the existence of RepeatValueBlocks, with the result that it inserts erroneous padding. For the "foo" string above, it would conclude that there were three elements in a four-element array, and add (24:UndefinedValueBlock) at the end of the list, giving two values at bit offset 24. This patch corrects the problem: --- padding.cpp 2000/07/12 14:12:51 1.1.1.1 +++ padding.cpp 2001/06/12 20:26:53 @@ -103,8 +103,16 @@ // we don't seem to have a way to detect this situation; we would need a span // value for the array type. - bit_offset += element_type->get_bit_size().c_int(); - count ++; + if (is_kind_of(pair.second)) { + RepeatValueBlock *rvb = (RepeatValueBlock *)pair.second; + bit_offset += rvb->get_num_repetitions() * + element_type->get_bit_size().c_int(); + count += rvb->get_num_repetitions(); + } + else { + bit_offset += element_type->get_bit_size().c_int(); + count ++; + } iter.next(); } IInteger offset = type->get_bit_size(); (I assume that the type of the RepeatValueBlock is the same as the type of the array; this is probably a reasonable assumption. I haven't looked to see whether a similar bug affects the GroupType variant of Padding::rebuild_value_block().)