This is an archive of the discontinued LLVM Phabricator instance.

[ubsan] Diagnose invalid uses of builtins (clang)
ClosedPublic

Authored by vsk on Jun 23 2017, 8:36 PM.

Details

Summary

On some targets, passing zero to the clz() or ctz() builtins has
undefined behavior. I ran into this issue while debugging UB in
__hash_table from libcxx: the bug I was seeing manifested itself
differently under -O0 vs -Os, due to a UB call to clz() (see:
libcxx/r304617).

This patch introduces a check which can detect UB calls to builtins.

llvm.org/PR26979

Diff Detail

Repository
rL LLVM

Event Timeline

efriedma resigned from this revision.Jun 26 2017, 5:27 PM

The check itself looks okay, but I'm not really familiar with the other ubsan bits.

vsk edited reviewers, added: eugenis; removed: efriedma.Jul 28 2017, 2:51 PM

Ping.

eugenis accepted this revision.Jul 28 2017, 4:19 PM

Looks fine to me.

This revision is now accepted and ready to land.Jul 28 2017, 4:19 PM
This revision was automatically updated to reflect the committed changes.