[llvm-commits] PATCH: Teach the InstVisitor to visit intrinsic CallInst subclasses

Chandler Carruth chandlerc at gmail.com
Mon Jul 30 14:25:34 PDT 2012


Hello,

In looking at some InstVisitor-based code that handles common intrinsics
similarly to instuctions, I see a common pattern of a big switch in them.
This is what the visitor pattern was designed to factor out of user code.

We also have really nice helper classes that wrap CallInst for intrinsic
calls. These are being ignored in the delegation hierarchy of the
InstVisitor.

The attached patch fixes this by having the visitor specially delegate
through CallInst instructions into specialized intrinsic visitors as
appropriate. Historically, this used to be avoided because it necessitated
a string lookup for the intrinsic, but today it's a simple switch.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120730/1e09e38e/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: instvisitor-intrinsics.patch
Type: application/octet-stream
Size: 3927 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120730/1e09e38e/attachment.obj>


More information about the llvm-commits mailing list