datalayout optimization question

Hi all,

We are developing our own compiler front-end and use LLVM as back-end. We generate .ll files and use opt/llc to generate target specific code. When I generate datalayout information in my .ll file it seems that it enables more optimization from LLVM opt. How can I determine which optimization are driven by datalayout information generation ?

In other words, when I don’t generate target specific datalayout information, what are the optimizations that are turned off ?

Thanks for answers

Best Regards

Seb

Are you expecting to use a single set of IR files to generate code for multiple targets? Otherwise I'm not sure why your .ll files would necessarily lack the data layout information. The reason I ask is that LLVM IR is fundamentally not target independent in ways far beyond the presence or absence of the data layout string.

For gory details: http://lists.cs.uiuc.edu/pipermail/llvmdev/2011-October/043719.html.

Beyond that, rather large, caveat, I'm not sure of the answer to your specific question. It's not so much which optimizations are turned off, per se, but rather that some won't have the information they need (alignment data, for example) to do a good job, so they'll miss opportunities.

Regards,
  Jim

Hi Sebastien,

We are developing our own compiler front-end and use LLVM as back-end. We
generate .ll files and use opt/llc to generate target specific code. When I
generate datalayout information in my .ll file it seems that it enables more
optimization from LLVM opt. How can I determine which optimization are driven by
datalayout information generation ?

In other words, when I don’t generate target specific datalayout information,
what are the optimizations that are turned off ?

this will give you an idea:

   grep -l -r TargetData llvm/lib/Transforms

Several of these work in a degraded mode if they don't have target data, i.e.
they still do some optimizations, just not all of them. Finally, there are a
few optimizations that could in theory be performed without target data but
aren't because either no-one implemented it, or it is tricky and didn't seem
worth it.

Ciao, Duncan.

Hi Jim,

First of all, thanks for the quick answer. I'm just asking this question because in presence of target specific 'datalayout' information I see significant speed-up on benchmarks, in certain rare cases I also see slowdowns. So before digging into the sources to understand what's going on, I wanted to understand if there is an identified set of optimizations that are known to benefit of 'datalayout' information.

Best Regards
Seb