[PATCH] ubsan: Emit branch metadata

As previously discussed, default block placement for ubsan handler
blocks (when recoverable) are suboptimal and cause poor icache

Attached is a simple patch adding strong branch hints to ensure proper
block placement.

Also, I've attached an extended version of the previous set of
experiments that includes results for this change vs without this
change, as well as the similarly isolated impact of using the ColdCC

In summary, this minor change brings overall slowdown from 34% to 23%,
and relative to NoRecover from 20% to 10%.

Easy win :).

Ok to commit?


0001-ubsan-Emit-branch-weight-metadata-to-hint-towards-co.patch (1.25 KB)

recover.pdf (7.77 KB)

To match the 'unreachable' weights, please use 1<<20 - 1, not 1<<20
(see lib/Analysis/BranchProbabilityInfo.cpp's UR_NONTAKEN_WEIGHT), and
also add a comment explaining where this number comes from. Please
update one of Clang's ubsan IRGen tests to check that the metadata is
being created. Then feel free to commit. Thanks!