On 28/02/12 17:48, John Regehr wrote:>> void t2(double *x) >> { >> long long a[2]; >> a[0] = 3; >> a[1] = 5; >> *x = * ((double *) a); >> *(x+1) = * ((double *) &a[a[0]-2]); >> } > > Doesn't this code violate the strict aliasing rules?Maybe, but the LLVM IR he showed seems perfectly well defined. Ciao, Duncan.
Hi all, If I remove datalayout definition, code is not optimized and work as expected. So my question is: What attribute/value/interpretation of data-layout would cause this type of bug? Thanks for your answers Seb 2012/2/28 Duncan Sands <baldrick at free.fr>> On 28/02/12 17:48, John Regehr wrote: > >> void t2(double *x) > >> { > >> long long a[2]; > >> a[0] = 3; > >> a[1] = 5; > >> *x = * ((double *) a); > >> *(x+1) = * ((double *) &a[a[0]-2]); > >> } > > > > Doesn't this code violate the strict aliasing rules? > > Maybe, but the LLVM IR he showed seems perfectly well defined. > > Ciao, Duncan. > _______________________________________________ > 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/20120229/1fb33ac0/attachment.html>
Hi Seb,> If I remove datalayout definition, code is not optimized and work as expected. > So my question is: > > What attribute/value/interpretation of data-layout would cause this type of bug?all kinds of optimizers use datalayout (and are disabled if there is none). For example, alias analysis, anything that needs to understand getelementptr offsets, the list is endless. I suggest you open a bug report, describing your original problem as in your first email. Ciao, Duncan.> Thanks for your answers > Seb > > 2012/2/28 Duncan Sands <baldrick at free.fr <mailto:baldrick at free.fr>> > > On 28/02/12 17:48, John Regehr wrote: > >> void t2(double *x) > >> { > >> long long a[2]; > >> a[0] = 3; > >> a[1] = 5; > >> *x = * ((double *) a); > >> *(x+1) = * ((double *) &a[a[0]-2]); > >> } > > > > Doesn't this code violate the strict aliasing rules? > > Maybe, but the LLVM IR he showed seems perfectly well defined. > > Ciao, Duncan. > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu <mailto:LLVMdev at cs.uiuc.edu> http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >