r243115 - LLVM API Change: the Module always owns the DataLayout
Mehdi Amini
mehdi.amini at apple.com
Fri Jul 24 09:04:30 PDT 2015
Author: mehdi_amini
Date: Fri Jul 24 11:04:29 2015
New Revision: 243115
URL: http://llvm.org/viewvc/llvm-project?rev=243115&view=rev
Log:
LLVM API Change: the Module always owns the DataLayout
From: Mehdi Amini <mehdi.amini at apple.com>
Modified:
cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
cfe/trunk/lib/CodeGen/CodeGenTypes.h
cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
Modified: cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h?rev=243115&r1=243114&r2=243115&view=diff
==============================================================================
--- cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h (original)
+++ cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h Fri Jul 24 11:04:29 2015
@@ -50,7 +50,7 @@ class CodeGenModule;
class CodeGenABITypes
{
public:
- CodeGenABITypes(ASTContext &C, llvm::Module &M, const llvm::DataLayout &TD,
+ CodeGenABITypes(ASTContext &C, llvm::Module &M,
CoverageSourceInfo *CoverageInfo = nullptr);
~CodeGenABITypes();
Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=243115&r1=243114&r2=243115&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Fri Jul 24 11:04:29 2015
@@ -608,7 +608,7 @@ void EmitAssemblyHelper::EmitAssembly(Ba
if (UsesCodeGen && !TM)
return;
if (TM)
- TheModule->setDataLayout(*TM->getDataLayout());
+ TheModule->setDataLayout(TM->createDataLayout());
CreatePasses();
switch (Action) {
@@ -670,8 +670,7 @@ void clang::EmitBackendOutput(Diagnostic
// If an optional clang TargetInfo description string was passed in, use it to
// verify the LLVM TargetMachine's DataLayout.
if (AsmHelper.TM && !TDesc.empty()) {
- std::string DLDesc =
- AsmHelper.TM->getDataLayout()->getStringRepresentation();
+ std::string DLDesc = M->getDataLayout().getStringRepresentation();
if (DLDesc != TDesc) {
unsigned DiagID = Diags.getCustomDiagID(
DiagnosticsEngine::Error, "backend data layout '%0' does not match "
Modified: cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp?rev=243115&r1=243114&r2=243115&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp Fri Jul 24 11:04:29 2015
@@ -26,17 +26,12 @@
using namespace clang;
using namespace CodeGen;
-CodeGenABITypes::CodeGenABITypes(ASTContext &C,
- llvm::Module &M,
- const llvm::DataLayout &TD,
+CodeGenABITypes::CodeGenABITypes(ASTContext &C, llvm::Module &M,
CoverageSourceInfo *CoverageInfo)
- : CGO(new CodeGenOptions),
- HSO(new HeaderSearchOptions),
- PPO(new PreprocessorOptions),
- CGM(new CodeGen::CodeGenModule(C, *HSO, *PPO, *CGO,
- M, TD, C.getDiagnostics(),
- CoverageInfo)) {
-}
+ : CGO(new CodeGenOptions), HSO(new HeaderSearchOptions),
+ PPO(new PreprocessorOptions),
+ CGM(new CodeGen::CodeGenModule(C, *HSO, *PPO, *CGO, M, C.getDiagnostics(),
+ CoverageInfo)) {}
CodeGenABITypes::~CodeGenABITypes()
{
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=243115&r1=243114&r2=243115&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Jul 24 11:04:29 2015
@@ -77,12 +77,11 @@ static CGCXXABI *createCXXABI(CodeGenMod
CodeGenModule::CodeGenModule(ASTContext &C, const HeaderSearchOptions &HSO,
const PreprocessorOptions &PPO,
const CodeGenOptions &CGO, llvm::Module &M,
- const llvm::DataLayout &TD,
DiagnosticsEngine &diags,
CoverageSourceInfo *CoverageInfo)
: Context(C), LangOpts(C.getLangOpts()), HeaderSearchOpts(HSO),
PreprocessorOpts(PPO), CodeGenOpts(CGO), TheModule(M), Diags(diags),
- TheDataLayout(TD), Target(C.getTargetInfo()), ABI(createCXXABI(*this)),
+ Target(C.getTargetInfo()), ABI(createCXXABI(*this)),
VMContext(M.getContext()), TBAA(nullptr), TheTargetCodeGenInfo(nullptr),
Types(*this), VTables(*this), ObjCRuntime(nullptr),
OpenCLRuntime(nullptr), OpenMPRuntime(nullptr), CUDARuntime(nullptr),
@@ -1893,8 +1892,8 @@ void CodeGenModule::EmitTentativeDefinit
}
CharUnits CodeGenModule::GetTargetTypeStoreSize(llvm::Type *Ty) const {
- return Context.toCharUnitsFromBits(
- TheDataLayout.getTypeStoreSizeInBits(Ty));
+ return Context.toCharUnitsFromBits(
+ getDataLayout().getTypeStoreSizeInBits(Ty));
}
unsigned CodeGenModule::GetGlobalVarAddressSpace(const VarDecl *D,
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=243115&r1=243114&r2=243115&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Fri Jul 24 11:04:29 2015
@@ -285,7 +285,6 @@ private:
const CodeGenOptions &CodeGenOpts;
llvm::Module &TheModule;
DiagnosticsEngine &Diags;
- const llvm::DataLayout &TheDataLayout;
const TargetInfo &Target;
std::unique_ptr<CGCXXABI> ABI;
llvm::LLVMContext &VMContext;
@@ -492,11 +491,9 @@ private:
std::unique_ptr<CoverageMappingModuleGen> CoverageMapping;
public:
- CodeGenModule(ASTContext &C,
- const HeaderSearchOptions &headersearchopts,
+ CodeGenModule(ASTContext &C, const HeaderSearchOptions &headersearchopts,
const PreprocessorOptions &ppopts,
- const CodeGenOptions &CodeGenOpts,
- llvm::Module &M, const llvm::DataLayout &TD,
+ const CodeGenOptions &CodeGenOpts, llvm::Module &M,
DiagnosticsEngine &Diags,
CoverageSourceInfo *CoverageInfo = nullptr);
@@ -614,7 +611,9 @@ public:
const CodeGenOptions &getCodeGenOpts() const { return CodeGenOpts; }
llvm::Module &getModule() const { return TheModule; }
DiagnosticsEngine &getDiags() const { return Diags; }
- const llvm::DataLayout &getDataLayout() const { return TheDataLayout; }
+ const llvm::DataLayout &getDataLayout() const {
+ return TheModule.getDataLayout();
+ }
const TargetInfo &getTarget() const { return Target; }
const llvm::Triple &getTriple() const;
bool supportsCOMDAT() const;
Modified: cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTypes.cpp?rev=243115&r1=243114&r2=243115&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenTypes.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTypes.cpp Fri Jul 24 11:04:29 2015
@@ -31,7 +31,6 @@ using namespace CodeGen;
CodeGenTypes::CodeGenTypes(CodeGenModule &cgm)
: CGM(cgm), Context(cgm.getContext()), TheModule(cgm.getModule()),
- TheDataLayout(cgm.getDataLayout()),
Target(cgm.getTarget()), TheCXXABI(cgm.getCXXABI()),
TheABIInfo(cgm.getTargetCodeGenInfo().getABIInfo()) {
SkippedLayout = false;
Modified: cfe/trunk/lib/CodeGen/CodeGenTypes.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTypes.h?rev=243115&r1=243114&r2=243115&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenTypes.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTypes.h Fri Jul 24 11:04:29 2015
@@ -122,7 +122,6 @@ class CodeGenTypes {
// Some of this stuff should probably be left on the CGM.
ASTContext &Context;
llvm::Module &TheModule;
- const llvm::DataLayout &TheDataLayout;
const TargetInfo &Target;
CGCXXABI &TheCXXABI;
@@ -168,7 +167,9 @@ public:
CodeGenTypes(CodeGenModule &cgm);
~CodeGenTypes();
- const llvm::DataLayout &getDataLayout() const { return TheDataLayout; }
+ const llvm::DataLayout &getDataLayout() const {
+ return TheModule.getDataLayout();
+ }
ASTContext &getContext() const { return Context; }
const ABIInfo &getABIInfo() const { return TheABIInfo; }
const TargetInfo &getTarget() const { return Target; }
Modified: cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ModuleBuilder.cpp?rev=243115&r1=243114&r2=243115&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/ModuleBuilder.cpp (original)
+++ cfe/trunk/lib/CodeGen/ModuleBuilder.cpp Fri Jul 24 11:04:29 2015
@@ -30,7 +30,6 @@ using namespace clang;
namespace {
class CodeGeneratorImpl : public CodeGenerator {
DiagnosticsEngine &Diags;
- std::unique_ptr<const llvm::DataLayout> TD;
ASTContext *Ctx;
const HeaderSearchOptions &HeaderSearchOpts; // Only used for debug info.
const PreprocessorOptions &PreprocessorOpts; // Only used for debug info.
@@ -100,13 +99,9 @@ namespace {
M->setTargetTriple(Ctx->getTargetInfo().getTriple().getTriple());
M->setDataLayout(Ctx->getTargetInfo().getTargetDescription());
- TD.reset(
- new llvm::DataLayout(Ctx->getTargetInfo().getTargetDescription()));
- Builder.reset(new CodeGen::CodeGenModule(Context,
- HeaderSearchOpts,
- PreprocessorOpts,
- CodeGenOpts, *M, *TD,
- Diags, CoverageInfo));
+ Builder.reset(new CodeGen::CodeGenModule(Context, HeaderSearchOpts,
+ PreprocessorOpts, CodeGenOpts,
+ *M, Diags, CoverageInfo));
for (size_t i = 0, e = CodeGenOpts.DependentLibraries.size(); i < e; ++i)
HandleDependentLibrary(CodeGenOpts.DependentLibraries[i]);
Modified: cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp?rev=243115&r1=243114&r2=243115&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp (original)
+++ cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp Fri Jul 24 11:04:29 2015
@@ -75,9 +75,8 @@ public:
VMContext.reset(new llvm::LLVMContext());
M.reset(new llvm::Module(MainFileName, *VMContext));
M->setDataLayout(Ctx->getTargetInfo().getTargetDescription());
- Builder.reset(new CodeGen::CodeGenModule(*Ctx, HeaderSearchOpts,
- PreprocessorOpts, CodeGenOpts, *M,
- M->getDataLayout(), Diags));
+ Builder.reset(new CodeGen::CodeGenModule(
+ *Ctx, HeaderSearchOpts, PreprocessorOpts, CodeGenOpts, *M, Diags));
}
/// Emit a container holding the serialized AST.
More information about the cfe-commits
mailing list