public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* [Bug translator/18884] New: const-folded literals get unnecessary tmp storage
@ 2015-08-28 18:57 jistone at redhat dot com
  2015-11-25  5:26 ` [Bug translator/18884] " jistone at redhat dot com
  0 siblings, 1 reply; 2+ messages in thread
From: jistone at redhat dot com @ 2015-08-28 18:57 UTC (permalink / raw)
  To: systemtap

https://sourceware.org/bugzilla/show_bug.cgi?id=18884

            Bug ID: 18884
           Summary: const-folded literals get unnecessary tmp storage
           Product: systemtap
           Version: unspecified
            Status: NEW
          Severity: minor
          Priority: P2
         Component: translator
          Assignee: systemtap at sourceware dot org
          Reporter: jistone at redhat dot com
  Target Milestone: ---

Thanks to the const-folding pass, trivial numeric and string operations are
reduced in pass-2.  You can see this in -vp2 of the following probes:

  probe oneshot { println("foobar") }
  probe oneshot { println("foo" . "bar") }

The second one becomes just like the first, as println("foobar").

In the translator pass, we also try to avoid tmp copies of literal values, and
instead just emit the values directly into their expressions.  However, this is
compared on the tok->type rather than checking if the expression itself is a
literal.  The pattern in translate.cxx looks like this:

  if (val->tok->type == tok_number || val->tok->type == tok_string)
    tmpval.override(c_expression(val))

This is basically everywhere c_expression is called, and c_expression itself
also asserts the tok->type.

But in the case of "foo"."bar", const_folder::visit_concatenation points the
new literal_string's tok at the original "." operator, which is not a
tok_string.  That's useful for accurate error reporting, but it means the
translator shouldn't rely on tok->type being accurate.

The difference is visible in pass-3:

$ stap -p3 -e 'probe oneshot { println("foobar") }' | grep -c tmp
0
$ stap -p3 -e 'probe oneshot { println("foo"."bar") }' | grep -c tmp
4

This might also occur in other places where we synthesize code with literals,
tied back to original tokens, like saved $var in .return probes, but I haven't
checked for sure.

-- 
You are receiving this mail because:
You are the assignee for the bug.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug translator/18884] const-folded literals get unnecessary tmp storage
  2015-08-28 18:57 [Bug translator/18884] New: const-folded literals get unnecessary tmp storage jistone at redhat dot com
@ 2015-11-25  5:26 ` jistone at redhat dot com
  0 siblings, 0 replies; 2+ messages in thread
From: jistone at redhat dot com @ 2015-11-25  5:26 UTC (permalink / raw)
  To: systemtap

https://sourceware.org/bugzilla/show_bug.cgi?id=18884

Josh Stone <jistone at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #1 from Josh Stone <jistone at redhat dot com> ---
commit b2d74f03a0c5536dcc2c7b6af262cfdc5459e947

-- 
You are receiving this mail because:
You are the assignee for the bug.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-11-25  5:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-28 18:57 [Bug translator/18884] New: const-folded literals get unnecessary tmp storage jistone at redhat dot com
2015-11-25  5:26 ` [Bug translator/18884] " jistone at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).