This is an archive of the discontinued LLVM Phabricator instance.

[clang][dataflow] Add support for clang's `__builtin_expect`.
ClosedPublic

Authored by ymandel on Apr 1 2022, 8:05 AM.

Details

Summary

This patch adds basic modeling of __builtin_expect, just to propagate the
(first) argument, making the call transparent.

Driveby: adds tests for proper handling of some other builtins.

Diff Detail

Event Timeline

ymandel created this revision.Apr 1 2022, 8:05 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 1 2022, 8:05 AM
ymandel requested review of this revision.Apr 1 2022, 8:05 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 1 2022, 8:05 AM
sgatev accepted this revision.Apr 1 2022, 9:00 AM
This revision is now accepted and ready to land.Apr 1 2022, 9:00 AM
xazax.hun accepted this revision.Apr 1 2022, 9:08 AM

Nice!

Speaking of builtins, it might be great to add tests for __builtin_unreachable, __builtin_trap, __builtin_debugtrap. The CFG might already have the right shape so we might not need to add any code to support them. But it would be nice to know :) Maybe we could even add a comment to VisitCallExpr why those wouldn't need explicit support.

ymandel updated this revision to Diff 419802.Apr 1 2022, 10:44 AM

add tests for other builtins.

ymandel edited the summary of this revision. (Show Details)Apr 1 2022, 10:48 AM
sgatev accepted this revision.Apr 3 2022, 10:49 PM