Fix some dead-code pass bugs

Fix #10865 and #10939.