[patch] Simplify the datalayout strings by using the defaults

Rafael EspĂ­ndola rafael.espindola at gmail.com
Thu Dec 12 15:48:57 PST 2013

On 12 December 2013 13:28, David Peixotto <dpeixott at codeaurora.org> wrote:
> Sorry I'm joining the conversation a bit late, but these look like good changes.


> Are you planning to make the corresponding refactoring/defaulting changes to the data layout strings in clang (e.g. DescriptionString in lib/Basic/Targets.cpp)?

Excellent question. The short answer is yes, I need to change those
too so that clang produces IR files that the mangler can handle
without a target machine. I also really want to remove the

I am not completely sure what the best way to do it is. I noticed that
clang always creates a TargetMachine, so my first tough was to just
create it earlier and use the DataLayout created by LLVM. The problem
is that in some cases the TargetMachine we create is the cpp one
(llvm.org/pr18235), which has no DataLayout.

The 3 options I have in mind right now are:
* Create a trivial llvm target for le32 and spir and create the target
machine earlier (which would then always work).
* Try to create the target machine early, and if that fails, fallback
to getTargetDescription. The getTargetDescription of the "real"
targets would error.
* Have a static helper in DataLayout to create the string given a llvm::Triple.

The first 2 options seem more structured, but they have some disadvantages:

* It would not be possible to print IR for ARM on a clang built with
-DLLVM_TARGETS_TO_BUILD=x86. Not sure how common this is.
* With the first option implementing something like le32 or spir would
require a dummy target on LLVM.

Any thought on which one would work better?


More information about the llvm-commits mailing list