1. A method for counting speculatively-executed instructions for performance analysis purposes, comprising: counting instructions which are normally executed during a normal-execution mode on a processor, wherein counting instructions involves incrementing an instruction counter when an instruction is executed during the normal-execution mode; entering a speculative-execution mode wherein instructions are speculatively executed without being committed to the architectural state of the processor, wherein the speculative-execution mode includes: an execute-ahead mode, wherein instructions that cannot be executed because of an unresolved data dependency are deferred, and wherein other non-deferred instructions are executed in program order; and a deferred mode wherein deferred instructions are executed in program order, and wherein deferred instructions that still cannot be executed because of unresolved data dependencies are deferred again; checkpointing a value of the instruction counter; counting the speculatively-executed instructions during the speculative-execution mode, wherein counting the speculatively-executed instructions involves incrementing the instruction counter as an instruction is encountered during the execute-ahead mode even if the instruction is deferred, and not counting any deferred instructions when the deferred instructions are executed in deferred mode; and if the speculative-execution mode does not complete successfully, restoring the value of the instruction counter from the checkpoint.