IMPALA-789: Runtime profile averages are not computed correctly.

This defect was caused by incorrectly aggregating intermediate
runtime profiles in the patch for IMPALA-540. Runtime profiles
were being summed instead of averaged.
In this patch, a new AveragedCounter is introduced to maintain a
fragment's average_profile. A fragment's average_profile will now
be the average of the current fragment instance profiles

Change-Id: I2b808023e6206e2e36513f649a16f8c2157f6bb2
Reviewed-on: http://gerrit.ent.cloudera.com:8080/1812
Reviewed-by: Srinath Shankar <sshankar@cloudera.com>
Tested-by: jenkins
IMPALA-765: Fix subexpr elimination codegen optimization.

The previous implementation did not properly handle replacing the is_null
return argument from expr calls.

Change-Id: I96cd0dfca8876b4f914b0cbc4eb459ea3dcdf230
Reviewed-on: http://gerrit.ent.cloudera.com:8080/1838
Reviewed-by: Nong Li <nong@cloudera.com>
Tested-by: jenkins