]> sourceware.org Git - systemtap.git/commitdiff
Do liveness analysis after location information set and use regno info
authorWilliam Cohen <wcohen@redhat.com>
Wed, 22 Sep 2021 21:34:25 +0000 (17:34 -0400)
committerWilliam Cohen <wcohen@redhat.com>
Tue, 26 Oct 2021 13:57:22 +0000 (09:57 -0400)
Initially the call to the liveness analysis was being done before
the location information was setup.  Relocated the call after the
location information has been setup.

Corrected liveness analysis code to use the register number.  Also
added print out the function the liveness analysis is being run on.
Note that for probes on inlined functions this name will be different
than the probe point function name, it will be the actual function
that the code was inlined into.

analysis.cxx
tapsets.cxx

index 60962f245a0ed026c8930daf354c3a772f0fb956..2c0da978a920360438868315af2fa8ea35a5d8f2 100644 (file)
@@ -199,7 +199,6 @@ int liveness(const char *executable,
        // Determine whether 32-bit or 64-bit code as the register names are different in dyninst
        int reg_width = func_to_analyze.co->cs()->getAddressWidth();
 
-       #if 0
        // Find where the variable is located
        location *loc = ctx.locations.back ();
 
@@ -207,10 +206,7 @@ int liveness(const char *executable,
        if (loc->type != loc_register) return 0;
 
        // Map dwarf number to dyninst register name, punt if out of range
-       unsigned int regno = loc->offset;
-       #else
-       unsigned int regno = 5; // Dummy up to arg1 of x86
-       #endif
+       unsigned int regno = loc->regno;
        switch (reg_width){
        case 4:
                if (regno >= (sizeof(dyninst_register_32)/sizeof(MachRegister))) return 0;
@@ -248,7 +244,8 @@ int liveness(const char *executable,
        // Query to see if whether the register is live at that point
        bool used;
        la.query(iloc, LivenessAnalyzer::Before, r, used);
-       cout << "liveness analysis " << executable << " " << hex << addr << endl;
+       cout << "liveness analysis " << executable << " " << func->name()
+            << " " << hex << addr << endl;
        cout << r.name() <<  (used ? " used"  : " unused") << endl;
        return (used ? 1 : -1);
 }
index 348d9c613c04aeb86f3b33958d89f638416fe195..f4876cc5fd7dff533ab59029c1f5a5d1e8de7338 100644 (file)
@@ -4721,13 +4721,6 @@ dwarf_var_expanding_visitor::visit_target_symbol (target_symbol *e)
       ctx.pc = addr;
       ctx.userspace_p = userspace_p;
 
-      // Check if change to variable has any effect
-      if (lvalue) {
-             if (liveness(q.dw.module_name.c_str(), addr, ctx) < 0) {
-                     // warn that the write has no effect
-             }
-      }
-
       // NB: pass the ctx.e (copied/rewritten veraion e, not orig_e),
       // so [x] index expressions have their intra-synthetic-function names
       Dwarf_Die endtype;
@@ -4737,6 +4730,13 @@ dwarf_var_expanding_visitor::visit_target_symbol (target_symbol *e)
        q.dw.literal_stmt_for_local (ctx, getscopes(e), e->sym_name(),
                                     ctx.e, lvalue, &endtype);
 
+      // Now that have location information check if change to variable has any effect
+      if (lvalue) {
+             if (liveness(q.dw.module_name.c_str(), addr, ctx) < 0) {
+                     // FIXME: warn that the write has no effect
+             }
+      }
+
       q.dw.sess.globals.insert(q.dw.sess.globals.end(),
                               ctx.globals.begin(),
                               ctx.globals.end());
This page took 0.041793 seconds and 5 git commands to generate.