-
Notifications
You must be signed in to change notification settings - Fork 273
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
Set function member in instructions #1843
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -386,21 +386,12 @@ class goto_program_templatet | |
return t; | ||
} | ||
|
||
static const irep_idt get_function_id( | ||
const_targett l) | ||
{ | ||
while(!l->is_end_function()) | ||
++l; | ||
|
||
return l->function; | ||
} | ||
|
||
static const irep_idt get_function_id( | ||
const goto_program_templatet<codeT, guardT> &p) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this use the typedef'd name? |
||
{ | ||
assert(!p.empty()); | ||
PRECONDITION(!p.empty()); | ||
|
||
return get_function_id(--p.instructions.end()); | ||
return p.instructions.back().function; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tautschnig, I grab it from behind now, making sure the current behaviour is unchanged. The only use of this is in dependency_graph.h for indexing the post_dominator map. There was another use in remove returns that was unnecessary (see below). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That was probably my doing/my fault. Can we just get rid of it completely instead? I'm not even sure that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. initialize overrides ait::initialize... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have virtual void initialize(const goto_programt &);
virtual void initialize(const goto_functionst::goto_functiont &); -> #1848. |
||
} | ||
|
||
template <typename Target> | ||
|
@@ -521,6 +512,22 @@ class goto_program_templatet | |
} | ||
} | ||
|
||
/// Sets the `function` member of each instruction if not yet set | ||
/// Note that a goto program need not be a goto function and therefore, | ||
/// we cannot do this in update(), but only at the level of | ||
/// of goto_functionst where goto programs are guaranteed to be | ||
/// named functions. | ||
void update_instructions_function(const irep_idt &function_id) | ||
{ | ||
for(auto &instruction : instructions) | ||
{ | ||
if(instruction.function.empty()) | ||
{ | ||
instruction.function = function_id; | ||
} | ||
} | ||
} | ||
|
||
/// Compute location numbers | ||
void compute_location_numbers() | ||
{ | ||
|
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.
Could you elaborate this comment to explain how the instructions_function are being updated.
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.
added param description