-
Notifications
You must be signed in to change notification settings - Fork 277
Enable perfect forwarding with irept/exprt/typet constructors #3502
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
Changes from all commits
c61a3ba
027760b
60e9284
c7d38df
c267421
3924933
83ed9a5
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 |
---|---|---|
|
@@ -421,7 +421,7 @@ class irept | |
|
||
const irept &find(const irep_namet &name) const; | ||
irept &add(const irep_namet &name); | ||
irept &add(const irep_namet &name, const irept &irep); | ||
irept &add(const irep_namet &name, irept irep); | ||
|
||
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. One variant with just 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. Done. |
||
const std::string &get_string(const irep_namet &name) const | ||
{ | ||
|
@@ -435,9 +435,13 @@ class irept | |
long long get_long_long(const irep_namet &name) const; | ||
|
||
void set(const irep_namet &name, const irep_idt &value) | ||
{ add(name).id(value); } | ||
void set(const irep_namet &name, const irept &irep) | ||
{ add(name, irep); } | ||
{ | ||
add(name, irept(value)); | ||
} | ||
void set(const irep_namet &name, irept irep) | ||
{ | ||
add(name, std::move(irep)); | ||
} | ||
void set(const irep_namet &name, const long long value); | ||
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. Since this will copy eventually, simply have one variant, with just 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. Done. |
||
|
||
void remove(const irep_namet &name); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ class ssa_exprt:public symbol_exprt | |
public: | ||
/// Constructor | ||
/// \param expr: Expression to be converted to SSA symbol | ||
explicit ssa_exprt(const exprt &expr) : symbol_exprt(irep_idt(), expr.type()) | ||
explicit ssa_exprt(const exprt &expr) : symbol_exprt(expr.type()) | ||
{ | ||
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. I kind of liked 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. I don't think 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. No, it doesn't, but I was hoping it would eventually. 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 can certainly put the |
||
set(ID_C_SSA_symbol, true); | ||
add(ID_expression, expr); | ||
|
@@ -42,15 +42,13 @@ class ssa_exprt:public symbol_exprt | |
if(original_expr.id() == ID_symbol) | ||
return to_symbol_expr(original_expr).get_identifier(); | ||
|
||
object_descriptor_exprt ode; | ||
ode.object() = original_expr; | ||
object_descriptor_exprt ode(original_expr); | ||
return to_symbol_expr(ode.root_object()).get_identifier(); | ||
} | ||
|
||
const ssa_exprt get_l1_object() const | ||
{ | ||
object_descriptor_exprt ode; | ||
ode.object()=get_original_expr(); | ||
object_descriptor_exprt ode(get_original_expr()); | ||
|
||
ssa_exprt root(ode.root_object()); | ||
root.set(ID_L0, get(ID_L0)); | ||
|
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.
moving a
dstring
may well be slower than copying it.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.
Will remove.
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.
Or actually: shouldn't we just define a move constructor for
dstringt
that actually is cheap? For the case thatirep_idt == std::string
we'd still want thestd::move
.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.
I have added a commit that adds efficient move construction/assignment to
dstringt
.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.
I am still not entirely convinced that we need those
std::move(id)
-- we wouldn't do it for an integer, say.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.
But we don't know whether
irep_idt
is astd::string
(where it would seem worthwhile) or adstringt
(where it's certainly unnecessary). But also that isn't something I want this PR to get blocked on, I'm happy to follow whatever I'm advised to do.