[LLVMdev] Incorrect loop optimization when building the Linux kernel

Sean Silva chisophugis at gmail.com
Mon Dec 8 16:53:55 PST 2014


On Sun, Dec 7, 2014 at 9:31 PM, Chengyu Song <csong84 at gatech.edu> wrote:

> > 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.
>

I don't think this code means the same thing. AFAIK this code says that
there is a pointer (to struct builtin_fw) in memory at __start_builtin_fw,
whereas the original code says that there is a `struct builtin_fw` (or zero
of them) in memory at __start_builtin_fw.

-- Sean Silva


>
> Sadly, Linux kernel may contain more such declarations.
>
> Thanks a lot!
> Chengyu
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20141208/b90b9792/attachment.html>


More information about the llvm-dev mailing list