[cfe-dev] inconsistent targetdata between clang and llvm
Roman Divacky
rdivacky at freebsd.org
Wed Jun 29 08:42:06 PDT 2011
Hi,
Clang has its own definition of TargetData which it uses in:
ModuleBuilder.cpp:Initialize():
virtual void Initialize(ASTContext &Context) {
Ctx = &Context;
M->setTargetTriple(Ctx->Target.getTriple().getTriple());
M->setDataLayout(Ctx->Target.getTargetDescription());
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.
Opinions?
roman
More information about the cfe-dev
mailing list