This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug translator/18884] New: const-folded literals get unnecessary tmp storage


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]