Fix some code suppression fallout

Some more subtle issues with code suppression:
- outputting asms but not their operand setup is broken
- but global asms must always be output
- statement expressions are transparent to code suppression
- vtop can't be transformed from VT_CMP/VT_JMP when nocode_wanted

Also remove .exe files from tests2 if they don't fail.
This commit is contained in:
Michael Matz
2016-12-20 04:49:22 +01:00
parent 559ee1e940
commit 42e2a67f23
8 changed files with 138 additions and 20 deletions

View File

@ -1404,6 +1404,15 @@ void optimize_out(void)
if (defined_function() && 0)
refer_to_undefined();
if (0) {
(void)sizeof( ({
do { } while (0);
0;
}) );
undefined_function();
}
/* Leave the "if(1)return; printf()" in this order and last in the function */
if (1)
return;
printf ("oor:%d\n", undefined_function());
@ -3251,6 +3260,28 @@ void trace_console(long len, long len2)
{
printf("huh?\n");
}
#endif
}
void test_asm_dead_code(void)
{
long rdi;
/* Try to make sure that xdi contains a zero, and hence will
lead to a segfault if the next asm is evaluated without
arguments being set up. */
asm volatile ("" : "=D" (rdi) : "0" (0));
(void)sizeof (({
int var;
/* This shouldn't trigger a segfault, either the argument
registers need to be set up and the asm emitted despite
this being in an unevaluated context, or both the argument
setup _and_ the asm emission need to be suppressed. The latter
is better. Disabling asm code gen when suppression is on
also fixes the above trace_console bug, but that came earlier
than asm suppression. */
asm volatile ("movl $0,(%0)" : : "D" (&var) : "memory");
var;
}));
}
void asm_test(void)
@ -3334,6 +3365,7 @@ void asm_test(void)
printf ("fancycpy2(%d)=%d\n", val, val2);
asm volatile ("mov $0x4243, %%esi" : "=r" (regvar));
printf ("regvar=%x\n", regvar);
test_high_clobbers();
trace_console(8, 8);
test_asm_dead_code();
return;