xref: /illumos-gate/usr/src/tools/smatch/src/validation/kill-load.c (revision 1f5207b7604fb44407eb4342aff613f7c4508508)
1*1f5207b7SJohn Levon int keep(volatile int *p)	{ return *p && 0; }
2*1f5207b7SJohn Levon int kill(int *p, int i)		{ return *p && 0; }
3*1f5207b7SJohn Levon void ind(volatile int *p,int i)	{ int v = i++; if (i && 0) p[v]; }
4*1f5207b7SJohn Levon 
5*1f5207b7SJohn Levon 
6*1f5207b7SJohn Levon /*
7*1f5207b7SJohn Levon  * check-name: kill-load
8*1f5207b7SJohn Levon  * check-command: test-linearize -Wno-decl $file
9*1f5207b7SJohn Levon  * check-description:
10*1f5207b7SJohn Levon  *	Check that loads are optimized away but only
11*1f5207b7SJohn Levon  *	when needed:
12*1f5207b7SJohn Levon  *	- non-volatile
13*1f5207b7SJohn Levon  *	- bb unreachable.
14*1f5207b7SJohn Levon  *
15*1f5207b7SJohn Levon  * check-output-ignore
16*1f5207b7SJohn Levon  * check-output-pattern-1-times: load\\.
17*1f5207b7SJohn Levon  */
18