This is split into two patches. The first patch reworks the vvp implementation of resolver networks to be akin to wide functors (as per my proposal on iverilog-devel), which allows all the driver values for a multiply-driven wire to be extracted by a VPI function. The second patch implements the $countdrivers function.
I have done some performance measurements on my new implementation of resolver networks, using a test case that instantiates wires with between 2 and 10 drivers. In all case, both run time and memory usage were slightly lower with the new implementation, so I'm reasonably confident that nobody is going to see a performance hit with this change.
The $countdrivers implementation does not yet support wires connected to island ports (it does output a suitable "sorry" message when it detects this case). This is going to take a bit more work.
Also attached is a patch for the test suite that adds a couple of tests for the $countdrivers functionality, and removes the check for the old warning message that $countdrivers was not supported.
First patch
Second patch
Test suite patch
Third compiler patch
Second test suite patch
I've attached a third patch which adds $countdrivers support for wires connected to islands. I believe the implementation of $countdrivers is now complete.
Also attached is a second patch for the test suite, which adds some tests for the new functionality.
Applied to git master.
Also applied to ivtest patches to git master.