[Mesa-dev] [PATCH] glsl: Annotate as_foo functions that the this pointer cannot be NULL
Matt Turner
mattst88 at gmail.com
Wed Mar 18 13:49:00 PDT 2015
On Wed, Mar 18, 2015 at 1:25 PM, Ian Romanick <idr at freedesktop.org> wrote:
> From: Ian Romanick <ian.d.romanick at intel.com>
>
> We use the idoim
typo: idiom
>
> ir_foo *x = y->as_foo();
> if (x == NULL)
> return;
>
> all over the place. GCC generates some quite lovely code for this.
> One such example:
>
> 340a5b: 83 7d 18 04 cmpl $0x4,0x18(%rbp)
> 340a5f: 0f 85 06 04 00 00 jne 340e6b
> 340a65: 48 85 ed test %rbp,%rbp
> 340a68: 0f 84 fd 03 00 00 je 340e6b
>
> This case used as_expression() (ir_type_expression is 4). Note that it
> checkes the ir_type, then checks that the pointer isn't NULL. There is
typo: checks
Like Ilia said, this is probably the perfect use for assume. Using assume,
Reviewed-by: Matt Turner <mattst88 at gmail.com>
More information about the mesa-dev
mailing list