[Bug tree-optimization/70128] New: Linux kernel div patching optimized away
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Mar 7 19:32:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70128
Bug ID: 70128
Summary: Linux kernel div patching optimized away
Product: gcc
Version: 6.0
URL: https://bugzilla.redhat.com/show_bug.cgi?id=1303147
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: jakub at gcc dot gnu.org
CC: rth at gcc dot gnu.org
Target Milestone: ---
Target: arm*-linux-gnueabi
Linux kernel in arch/arm/kernel/setup.c contains questionable code, reduced
into:
extern void v7_coherent_kern_range(unsigned long, unsigned long);
void patch_aeabi_idiv(void)
{
extern void __aeabi_uidiv(void);
extern void __aeabi_idiv(void);
unsigned long fn_addr;
fn_addr = ((unsigned long)&__aeabi_uidiv) & ~1;
((unsigned int *)fn_addr)[0] = 0xe730f110;
((unsigned int *)fn_addr)[1] = 0xe12fff1e;
v7_coherent_kern_range(fn_addr,fn_addr + 8);
fn_addr = ((unsigned long)&__aeabi_idiv) & ~1;
((unsigned int *)fn_addr)[0] = 0xe710f110;
((unsigned int *)fn_addr)[1] = 0xe12fff1e;
v7_coherent_kern_range(fn_addr,fn_addr + 8);
}
where even when this is compiled with -fno-strict-aliasing -Os (and lots of
other options), the ((unsigned int *)fn_addr)[0] are removed by tree DSE
(supposedly points-to analysis figures out that fn_addr points to a
FUNCTION_DECL and doesn't set pi->nonlocal, while for ((unsigned int
*)fn_addr)[1] it is already set.
The question is, is -fno-strict-aliasing meant to also disable some points-to
optimizations, or is the above considered invalid even with
-fno-strict-aliasing? Of course, the fix for the kernel is easy, just add an
optimization barrier on fn_addr (like asm ("" : "+g" (fn_addr))).
More information about the Gcc-bugs
mailing list