Aerodynamics are non-linear, but uphill when the rider is slower, it more closely approaches this ideal. Therefore uphill is the place to spend any excess effort on a time trial since your energy isn't spent beating the wrong end of an exponential drag curve. We can therefore conclude that your aero gain uphill is marginal, while the weight remains solidly true to Newton's 2nd and slows you down.
On a TT my simple rule? Got harder when going slower. Once over the hill and back to speed, the question is how much effort to back off. This gets into physiology and how soon you need to engage the phosphocreatine system again (another hill). I tend to back off to LT1 to allow recycling or recharging of the anaerobic system.
On my local 10 mile TT, there are a couple 2-3% hills of around 1 km. My fastest times are always when I can keep at least 26 mph over these hills, but that takes me about 500 watts and that hurts but I can recover because it is only a 20 minute effort with three small hills. So, once over them and back to 31 mph or so, I back off a bit down below FTP because I am then on a 1% decline and another hill is coming up and I need my anaerobic stores recharged as much as possible to maintain momentun. Unless one knows how many kilojoules of anaerobic energy they have in reserve and the recharge rate, it is usually better to pace a TT evenly because when you blow, it is done. But from a time to distance optimization, it is clear the harder efforts give you more bang for the buck the slower you are going (in the linear region especially)