[LLVMdev] Incorrect loop optimization when building the Linux kernel

Chengyu Song csong84 at gatech.edu
Sun Dec 7 21:31:43 PST 2014


> It's difficult to say without a full example, but I'm very suspicious
> of those global declarations. I think the compiler would be entirely
> justified in assuming you could *never* get from __start_builtin_fw to
> __end_builtin_fw, let alone on the first iteration: they're distinct
> array objects and by definition (within C99) can't overlap.

I think this should be the root cause. Once I changed the declaration to pointers (instead of arrays):

extern struct builtin_fw* __start_builtin_fw;
extern struct builtin_fw* __end_builtin_fw;

The generated code will not skip the first comparison.

Sadly, Linux kernel may contain more such declarations.

Thanks a lot!
Chengyu



More information about the llvm-dev mailing list