diff options
author | Xavier Leroy <xavier.leroy@inria.fr> | 2016-07-08 15:44:46 +0200 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@inria.fr> | 2016-07-08 15:44:46 +0200 |
commit | 4c7650c3eaf4dfbe5971864bf084e76f844051ee (patch) | |
tree | 32b5deb84cb3fd36f4baada8eed4ce108aed9599 /test/regression/volatile2.c | |
parent | e73d5db97cdb22cce2ee479469f62af3c4b6264a (diff) | |
download | compcert-kvx-4c7650c3eaf4dfbe5971864bf084e76f844051ee.tar.gz compcert-kvx-4c7650c3eaf4dfbe5971864bf084e76f844051ee.zip |
Unwanted partial constant propagation in 64-bit integer arguments to builtins
Here are two examples that cause an internal error in Asmexpand.ml:
volatile long long x; void f(unsigned int i) { x = i; }
unsigned g(unsigned i) { return __builtin_clzll(i); }
The argument "i" to builtin volatile store or __builtin_clzll is turned into a BA_splitlong(BA_int 0, BA <variable i>), which Asmexpand.ml doesn't know how to handle.
The fix (in AST.builtin_arg_ok) is to prevent this 'optimization' for all builtins except those of the "OK_all" kind, i.e. __builtin_annot.
Regression tests were added and tested on IA32. Need to retest on ARM and PowerPC.
Diffstat (limited to 'test/regression/volatile2.c')
-rw-r--r-- | test/regression/volatile2.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/test/regression/volatile2.c b/test/regression/volatile2.c index 3bad6ae2..bd2a93a3 100644 --- a/test/regression/volatile2.c +++ b/test/regression/volatile2.c @@ -13,6 +13,7 @@ unsigned char guc; signed short gss; unsigned short gus; int gi; +unsigned gu; float gf; double gd; long long gll; @@ -44,6 +45,8 @@ int main() TEST("global float", float, gf, 0.5, 256.0); TEST("global double", double, gd, 3.1415, 2.718); TEST("global long long", long long, gll, 0x123456789ABCDEFLL, 0x789ABCDEF1234567LL); + /* Test for unwanted partial constant propagation */ + *((volatile long long *) &gll) = gu; return 0; } |