inconsistent targetdata between clang and llvm


Clang has its own definition of TargetData which it uses in:


    virtual void Initialize(ASTContext &Context) {
      Ctx = &Context;

      TD.reset(new llvm::TargetData(Ctx->Target.getTargetDescription()));
      Builder.reset(new CodeGen::CodeGenModule(Context, CodeGenOpts,
                                               *M, *TD, Diags));

but when we create the TargetMachine in BackendUtil.cpp:AddEmitPasses():

  TargetMachine *TM = TheTarget->createTargetMachine(Triple, FeaturesStr);

the TargetMachine uses (completely independent) TargetData from llvm.

This is usually no problem because (from those that I checked) these two
usually match. But this is not the case for PowerPC where it differs and
causes lots of problems.

I think it's wrong to have two TargetData in clang and llvm. Clang should
force llvm to use its TargetData. I am not sure how to do this.