[llvm] r243089 - Revert "Remove access to the DataLayout in the TargetMachine"
Duncan P. N. Exon Smith
dexonsmith at apple.com
Mon Jul 27 11:18:32 PDT 2015
> On 2015-Jul-23, at 20:36, Mehdi Amini <mehdi.amini at apple.com> wrote:
>
> Author: mehdi_amini
> Date: Thu Jul 23 22:36:55 2015
> New Revision: 243089
>
> URL: http://llvm.org/viewvc/llvm-project?rev=243089&view=rev
> Log:
> Revert "Remove access to the DataLayout in the TargetMachine"
>
> This reverts commit 0f720d984f419c747709462f7476dff962c0bc41.
Please use SVN revisions instead of git hashes when you revert. You
might find utils/git-svn/git-svnrevert useful.
>
> It breaks clang too badly, I need to prepare a proper patch for clang
> first.
>
> From: Mehdi Amini <mehdi.amini at apple.com>
>
> Modified:
> llvm/trunk/examples/Kaleidoscope/Orc/fully_lazy/toy.cpp
> llvm/trunk/examples/Kaleidoscope/Orc/initial/toy.cpp
> llvm/trunk/examples/Kaleidoscope/Orc/lazy_codegen/toy.cpp
> llvm/trunk/examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp
> llvm/trunk/include/llvm/Target/TargetMachine.h
> llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
> llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp
> llvm/trunk/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h
> llvm/trunk/lib/LTO/LTOCodeGenerator.cpp
> llvm/trunk/lib/LTO/LTOModule.cpp
> llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp
> llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp
> llvm/trunk/lib/Target/TargetMachineC.cpp
> llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
> llvm/trunk/tools/llc/llc.cpp
> llvm/trunk/tools/lli/OrcLazyJIT.cpp
> llvm/trunk/tools/lli/OrcLazyJIT.h
>
> Modified: llvm/trunk/examples/Kaleidoscope/Orc/fully_lazy/toy.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/Kaleidoscope/Orc/fully_lazy/toy.cpp?rev=243089&r1=243088&r2=243089&view=diff
> ==============================================================================
> --- llvm/trunk/examples/Kaleidoscope/Orc/fully_lazy/toy.cpp (original)
> +++ llvm/trunk/examples/Kaleidoscope/Orc/fully_lazy/toy.cpp Thu Jul 23 22:36:55 2015
> @@ -717,7 +717,7 @@ public:
> M(new Module(GenerateUniqueName("jit_module_"),
> Session.getLLVMContext())),
> Builder(Session.getLLVMContext()) {
> - M->setDataLayout(Session.getTarget().createDataLayout());
> + M->setDataLayout(*Session.getTarget().getDataLayout());
> }
>
> SessionContext& getSession() { return Session; }
> @@ -1179,7 +1179,7 @@ public:
> {
> raw_string_ostream MangledNameStream(MangledName);
> Mangler::getNameWithPrefix(MangledNameStream, Name,
> - Session.getTarget().createDataLayout());
> + *Session.getTarget().getDataLayout());
> }
> return MangledName;
> }
>
> Modified: llvm/trunk/examples/Kaleidoscope/Orc/initial/toy.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/Kaleidoscope/Orc/initial/toy.cpp?rev=243089&r1=243088&r2=243089&view=diff
> ==============================================================================
> --- llvm/trunk/examples/Kaleidoscope/Orc/initial/toy.cpp (original)
> +++ llvm/trunk/examples/Kaleidoscope/Orc/initial/toy.cpp Thu Jul 23 22:36:55 2015
> @@ -716,7 +716,7 @@ public:
> M(new Module(GenerateUniqueName("jit_module_"),
> Session.getLLVMContext())),
> Builder(Session.getLLVMContext()) {
> - M->setDataLayout(Session.getTarget().createDataLayout());
> + M->setDataLayout(*Session.getTarget().getDataLayout());
> }
>
> SessionContext& getSession() { return Session; }
> @@ -1160,7 +1160,7 @@ public:
> typedef CompileLayerT::ModuleSetHandleT ModuleHandleT;
>
> KaleidoscopeJIT(SessionContext &Session)
> - : DL(Session.getTarget().createDataLayout()),
> + : DL(*Session.getTarget().getDataLayout()),
> CompileLayer(ObjectLayer, SimpleCompiler(Session.getTarget())) {}
>
> std::string mangle(const std::string &Name) {
> @@ -1201,7 +1201,7 @@ public:
> }
>
> private:
> - const DataLayout DL;
> + const DataLayout &DL;
> ObjLayerT ObjectLayer;
> CompileLayerT CompileLayer;
> };
>
> Modified: llvm/trunk/examples/Kaleidoscope/Orc/lazy_codegen/toy.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/Kaleidoscope/Orc/lazy_codegen/toy.cpp?rev=243089&r1=243088&r2=243089&view=diff
> ==============================================================================
> --- llvm/trunk/examples/Kaleidoscope/Orc/lazy_codegen/toy.cpp (original)
> +++ llvm/trunk/examples/Kaleidoscope/Orc/lazy_codegen/toy.cpp Thu Jul 23 22:36:55 2015
> @@ -716,7 +716,7 @@ public:
> M(new Module(GenerateUniqueName("jit_module_"),
> Session.getLLVMContext())),
> Builder(Session.getLLVMContext()) {
> - M->setDataLayout(Session.getTarget().createDataLayout());
> + M->setDataLayout(*Session.getTarget().getDataLayout());
> }
>
> SessionContext& getSession() { return Session; }
> @@ -1162,7 +1162,7 @@ public:
> typedef LazyEmitLayerT::ModuleSetHandleT ModuleHandleT;
>
> KaleidoscopeJIT(SessionContext &Session)
> - : DL(Session.getTarget().createDataLayout()),
> + : DL(*Session.getTarget().getDataLayout()),
> CompileLayer(ObjectLayer, SimpleCompiler(Session.getTarget())),
> LazyEmitLayer(CompileLayer) {}
>
> @@ -1204,7 +1204,7 @@ public:
> }
>
> private:
> - const DataLayout DL;
> + const DataLayout &DL;
> ObjLayerT ObjectLayer;
> CompileLayerT CompileLayer;
> LazyEmitLayerT LazyEmitLayer;
>
> Modified: llvm/trunk/examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp?rev=243089&r1=243088&r2=243089&view=diff
> ==============================================================================
> --- llvm/trunk/examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp (original)
> +++ llvm/trunk/examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp Thu Jul 23 22:36:55 2015
> @@ -716,7 +716,7 @@ public:
> M(new Module(GenerateUniqueName("jit_module_"),
> Session.getLLVMContext())),
> Builder(Session.getLLVMContext()) {
> - M->setDataLayout(Session.getTarget().createDataLayout());
> + M->setDataLayout(*Session.getTarget().getDataLayout());
> }
>
> SessionContext& getSession() { return Session; }
> @@ -1170,7 +1170,7 @@ public:
> {
> raw_string_ostream MangledNameStream(MangledName);
> Mangler::getNameWithPrefix(MangledNameStream, Name,
> - Session.getTarget().createDataLayout());
> + *Session.getTarget().getDataLayout());
> }
> return MangledName;
> }
>
> Modified: llvm/trunk/include/llvm/Target/TargetMachine.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetMachine.h?rev=243089&r1=243088&r2=243089&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/Target/TargetMachine.h (original)
> +++ llvm/trunk/include/llvm/Target/TargetMachine.h Thu Jul 23 22:36:55 2015
> @@ -76,12 +76,7 @@ protected: // Can only create subclasses
> /// The Target that this machine was created for.
> const Target &TheTarget;
>
> - /// DataLayout for the target: keep ABI type size and alignment.
> - ///
> - /// The DataLayout is created based on the string representation provided
> - /// during construction. It is kept here only to avoid reparsing the string
> - /// but should not really be used during compilation, because it has an
> - /// internal cache that is context specific.
> + /// For ABI type size and alignment.
> const DataLayout DL;
>
> /// Triple string, CPU name, and target feature strings the TargetMachine
> @@ -130,13 +125,9 @@ public:
> return *static_cast<const STC*>(getSubtargetImpl(F));
> }
>
> - /// Create a DataLayout.
> - const DataLayout createDataLayout() const { return DL; }
> -
> - /// Get the pointer size for this target.
> - ///
> - /// This is the only time the DataLayout in the TargetMachine is used.
> - unsigned getPointerSize() const { return DL.getPointerSize(); }
> + /// This method returns a pointer to the DataLayout for the target. It should
> + /// be unchanging for every subtarget.
> + const DataLayout *getDataLayout() const { return &DL; }
>
> /// \brief Reset the target options based on the function's attributes.
> // FIXME: Remove TargetOptions that affect per-function code generation
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=243089&r1=243088&r2=243089&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Thu Jul 23 22:36:55 2015
> @@ -139,9 +139,9 @@ const DataLayout &AsmPrinter::getDataLay
> return MMI->getModule()->getDataLayout();
> }
>
> -// Do not use the cached DataLayout because some client use it without a Module
> -// (llmv-dsymutil, llvm-dwarfdump).
> -unsigned AsmPrinter::getPointerSize() const { return TM.getPointerSize(); }
> +unsigned AsmPrinter::getPointerSize() const {
> + return TM.getDataLayout()->getPointerSize();
> +}
>
> const MCSubtargetInfo &AsmPrinter::getSubtargetInfo() const {
> assert(MF && "getSubtargetInfo requires a valid MachineFunction!");
>
> Modified: llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp?rev=243089&r1=243088&r2=243089&view=diff
> ==============================================================================
> --- llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp (original)
> +++ llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp Thu Jul 23 22:36:55 2015
> @@ -68,7 +68,7 @@ MCJIT::createJIT(std::unique_ptr<Module>
> MCJIT::MCJIT(std::unique_ptr<Module> M, std::unique_ptr<TargetMachine> TM,
> std::shared_ptr<MCJITMemoryManager> MemMgr,
> std::shared_ptr<RuntimeDyld::SymbolResolver> Resolver)
> - : ExecutionEngine(TM->createDataLayout(), std::move(M)), TM(std::move(TM)),
> + : ExecutionEngine(*TM->getDataLayout(), std::move(M)), TM(std::move(TM)),
> Ctx(nullptr), MemMgr(std::move(MemMgr)),
> Resolver(*this, std::move(Resolver)), Dyld(*this->MemMgr, this->Resolver),
> ObjCache(nullptr) {
>
> Modified: llvm/trunk/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h?rev=243089&r1=243088&r2=243089&view=diff
> ==============================================================================
> --- llvm/trunk/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h (original)
> +++ llvm/trunk/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h Thu Jul 23 22:36:55 2015
> @@ -140,7 +140,7 @@ public:
> std::shared_ptr<MCJITMemoryManager> MemMgr,
> std::shared_ptr<RuntimeDyld::SymbolResolver> ClientResolver,
> std::unique_ptr<TargetMachine> TM)
> - : ExecutionEngine(TM->createDataLayout()), TM(std::move(TM)),
> + : ExecutionEngine(*TM->getDataLayout()), TM(std::move(TM)),
> MemMgr(*this, std::move(MemMgr)), Resolver(*this),
> ClientResolver(std::move(ClientResolver)), NotifyObjectLoaded(*this),
> NotifyFinalized(*this),
>
> Modified: llvm/trunk/lib/LTO/LTOCodeGenerator.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LTOCodeGenerator.cpp?rev=243089&r1=243088&r2=243089&view=diff
> ==============================================================================
> --- llvm/trunk/lib/LTO/LTOCodeGenerator.cpp (original)
> +++ llvm/trunk/lib/LTO/LTOCodeGenerator.cpp Thu Jul 23 22:36:55 2015
> @@ -521,7 +521,7 @@ bool LTOCodeGenerator::optimize(bool Dis
> legacy::PassManager passes;
>
> // Add an appropriate DataLayout instance for this module...
> - mergedModule->setDataLayout(TargetMach->createDataLayout());
> + mergedModule->setDataLayout(*TargetMach->getDataLayout());
>
> passes.add(
> createTargetTransformInfoWrapperPass(TargetMach->getTargetIRAnalysis()));
>
> Modified: llvm/trunk/lib/LTO/LTOModule.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LTOModule.cpp?rev=243089&r1=243088&r2=243089&view=diff
> ==============================================================================
> --- llvm/trunk/lib/LTO/LTOModule.cpp (original)
> +++ llvm/trunk/lib/LTO/LTOModule.cpp Thu Jul 23 22:36:55 2015
> @@ -232,7 +232,7 @@ LTOModule *LTOModule::makeLTOModule(Memo
>
> TargetMachine *target = march->createTargetMachine(TripleStr, CPU, FeatureStr,
> options);
> - M->setDataLayout(target->createDataLayout());
> + M->setDataLayout(*target->getDataLayout());
>
> std::unique_ptr<object::IRObjectFile> IRObj(
> new object::IRObjectFile(Buffer, std::move(M)));
>
> Modified: llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp?rev=243089&r1=243088&r2=243089&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp (original)
> +++ llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp Thu Jul 23 22:36:55 2015
> @@ -1370,7 +1370,7 @@ static SPCC::CondCodes FPCondCCodeToFCC(
> SparcTargetLowering::SparcTargetLowering(TargetMachine &TM,
> const SparcSubtarget &STI)
> : TargetLowering(TM), Subtarget(&STI) {
> - MVT PtrVT = MVT::getIntegerVT(8 * TM.getPointerSize());
> + auto &DL = *TM.getDataLayout();
>
> // Set up the register classes.
> addRegisterClass(MVT::i32, &SP::IntRegsRegClass);
> @@ -1396,10 +1396,10 @@ SparcTargetLowering::SparcTargetLowering
> setTruncStoreAction(MVT::f128, MVT::f64, Expand);
>
> // Custom legalize GlobalAddress nodes into LO/HI parts.
> - setOperationAction(ISD::GlobalAddress, PtrVT, Custom);
> - setOperationAction(ISD::GlobalTLSAddress, PtrVT, Custom);
> - setOperationAction(ISD::ConstantPool, PtrVT, Custom);
> - setOperationAction(ISD::BlockAddress, PtrVT, Custom);
> + setOperationAction(ISD::GlobalAddress, getPointerTy(DL), Custom);
> + setOperationAction(ISD::GlobalTLSAddress, getPointerTy(DL), Custom);
> + setOperationAction(ISD::ConstantPool, getPointerTy(DL), Custom);
> + setOperationAction(ISD::BlockAddress, getPointerTy(DL), Custom);
>
> // Sparc doesn't have sext_inreg, replace them with shl/sra
> setOperationAction(ISD::SIGN_EXTEND_INREG, MVT::i16, Expand);
>
> Modified: llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp?rev=243089&r1=243088&r2=243089&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp (original)
> +++ llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp Thu Jul 23 22:36:55 2015
> @@ -84,7 +84,8 @@ static MachineOperand earlyUseOperand(Ma
> SystemZTargetLowering::SystemZTargetLowering(const TargetMachine &TM,
> const SystemZSubtarget &STI)
> : TargetLowering(TM), Subtarget(STI) {
> - MVT PtrVT = MVT::getIntegerVT(8 * TM.getPointerSize());
> + auto &DL = *TM.getDataLayout();
> + MVT PtrVT = getPointerTy(DL);
>
> // Set up the register classes.
> if (Subtarget.hasHighWord())
>
> Modified: llvm/trunk/lib/Target/TargetMachineC.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetMachineC.cpp?rev=243089&r1=243088&r2=243089&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/TargetMachineC.cpp (original)
> +++ llvm/trunk/lib/Target/TargetMachineC.cpp Thu Jul 23 22:36:55 2015
> @@ -32,25 +32,15 @@
>
> using namespace llvm;
>
> -
> -// The TargetMachine uses to offer access to a DataLayout member. This is reflected
> -// in the C API. For backward compatibility reason, this structure allows to keep
> -// a DataLayout member accessible to C client that have a handle to a
> -// LLVMTargetMachineRef.
> -struct LLVMOpaqueTargetMachine {
> - std::unique_ptr<TargetMachine> Machine;
> - DataLayout DL;
> -};
> -
> -
> inline TargetMachine *unwrap(LLVMTargetMachineRef P) {
> - return P->Machine.get();
> + return reinterpret_cast<TargetMachine*>(P);
> }
> inline Target *unwrap(LLVMTargetRef P) {
> return reinterpret_cast<Target*>(P);
> }
> inline LLVMTargetMachineRef wrap(const TargetMachine *P) {
> - return new LLVMOpaqueTargetMachine{ std::unique_ptr<TargetMachine>(const_cast<TargetMachine*>(P)), P->createDataLayout() };
> + return
> + reinterpret_cast<LLVMTargetMachineRef>(const_cast<TargetMachine*>(P));
> }
> inline LLVMTargetRef wrap(const Target * P) {
> return reinterpret_cast<LLVMTargetRef>(const_cast<Target*>(P));
> @@ -157,7 +147,7 @@ LLVMTargetMachineRef LLVMCreateTargetMac
>
>
> void LLVMDisposeTargetMachine(LLVMTargetMachineRef T) {
> - delete T;
> + delete unwrap(T);
> }
>
> LLVMTargetRef LLVMGetTargetMachineTarget(LLVMTargetMachineRef T) {
> @@ -180,9 +170,8 @@ char* LLVMGetTargetMachineFeatureString(
> return strdup(StringRep.c_str());
> }
>
> -/// @deprecated: see "struct LLVMOpaqueTargetMachine" description above
> LLVMTargetDataRef LLVMGetTargetMachineData(LLVMTargetMachineRef T) {
> - return wrap(&T->DL);
> + return wrap(unwrap(T)->getDataLayout());
> }
>
> void LLVMSetTargetMachineAsmVerbosity(LLVMTargetMachineRef T,
> @@ -201,7 +190,14 @@ static LLVMBool LLVMTargetMachineEmit(LL
>
> std::string error;
>
> - Mod->setDataLayout(TM->createDataLayout());
> + const DataLayout *td = TM->getDataLayout();
> +
> + if (!td) {
> + error = "No DataLayout in TargetMachine";
> + *ErrorMessage = strdup(error.c_str());
> + return true;
> + }
> + Mod->setDataLayout(*td);
>
> TargetMachine::CodeGenFileType ft;
> switch (codegen) {
>
> Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=243089&r1=243088&r2=243089&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
> +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Thu Jul 23 22:36:55 2015
> @@ -76,7 +76,7 @@ X86TargetLowering::X86TargetLowering(con
> : TargetLowering(TM), Subtarget(&STI) {
> X86ScalarSSEf64 = Subtarget->hasSSE2();
> X86ScalarSSEf32 = Subtarget->hasSSE1();
> - MVT PtrVT = MVT::getIntegerVT(8 * TM.getPointerSize());
> + TD = TM.getDataLayout();
>
> // Set up the TargetLowering object.
> static const MVT IntVTs[] = { MVT::i8, MVT::i16, MVT::i32, MVT::i64 };
> @@ -505,7 +505,7 @@ X86TargetLowering::X86TargetLowering(con
> setOperationAction(ISD::STACKSAVE, MVT::Other, Expand);
> setOperationAction(ISD::STACKRESTORE, MVT::Other, Expand);
>
> - setOperationAction(ISD::DYNAMIC_STACKALLOC, PtrVT, Custom);
> + setOperationAction(ISD::DYNAMIC_STACKALLOC, getPointerTy(*TD), Custom);
>
> // GC_TRANSITION_START and GC_TRANSITION_END need custom lowering.
> setOperationAction(ISD::GC_TRANSITION_START, MVT::Other, Custom);
> @@ -16515,11 +16515,9 @@ SDValue X86TargetLowering::LowerINIT_TRA
>
> for (FunctionType::param_iterator I = FTy->param_begin(),
> E = FTy->param_end(); I != E; ++I, ++Idx)
> - if (Attrs.hasAttribute(Idx, Attribute::InReg)) {
> - auto &DL = DAG.getDataLayout();
> + if (Attrs.hasAttribute(Idx, Attribute::InReg))
> // FIXME: should only count parameters that are lowered to integers.
> - InRegCount += (DL.getTypeSizeInBits(*I) + 31) / 32;
> - }
> + InRegCount += (TD->getTypeSizeInBits(*I) + 31) / 32;
>
> if (InRegCount > 2) {
> report_fatal_error("Nest register in use - reduce number of inreg"
>
> Modified: llvm/trunk/tools/llc/llc.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llc/llc.cpp?rev=243089&r1=243088&r2=243089&view=diff
> ==============================================================================
> --- llvm/trunk/tools/llc/llc.cpp (original)
> +++ llvm/trunk/tools/llc/llc.cpp Thu Jul 23 22:36:55 2015
> @@ -312,7 +312,8 @@ static int compileModule(char **argv, LL
> PM.add(new TargetLibraryInfoWrapperPass(TLII));
>
> // Add the target data from the target machine, if it exists, or the module.
> - M->setDataLayout(Target->createDataLayout());
> + if (const DataLayout *DL = Target->getDataLayout())
> + M->setDataLayout(*DL);
>
> // Override function attributes based on CPUStr, FeaturesStr, and command line
> // flags.
>
> Modified: llvm/trunk/tools/lli/OrcLazyJIT.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lli/OrcLazyJIT.cpp?rev=243089&r1=243088&r2=243089&view=diff
> ==============================================================================
> --- llvm/trunk/tools/lli/OrcLazyJIT.cpp (original)
> +++ llvm/trunk/tools/lli/OrcLazyJIT.cpp Thu Jul 23 22:36:55 2015
> @@ -136,8 +136,7 @@ int llvm::runOrcLazyJIT(std::unique_ptr<
> }
>
> // Everything looks good. Build the JIT.
> - auto &DL = M->getDataLayout();
> - OrcLazyJIT J(std::move(TM), DL, Context, CallbackMgrBuilder);
> + OrcLazyJIT J(std::move(TM), Context, CallbackMgrBuilder);
>
> // Add the module, look up main and run it.
> auto MainHandle = J.addModule(std::move(M));
>
> Modified: llvm/trunk/tools/lli/OrcLazyJIT.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lli/OrcLazyJIT.h?rev=243089&r1=243088&r2=243089&view=diff
> ==============================================================================
> --- llvm/trunk/tools/lli/OrcLazyJIT.h (original)
> +++ llvm/trunk/tools/lli/OrcLazyJIT.h Thu Jul 23 22:36:55 2015
> @@ -46,17 +46,16 @@ public:
> CallbackManagerBuilder;
>
> static CallbackManagerBuilder createCallbackManagerBuilder(Triple T);
> - const DataLayout &DL;
>
> - OrcLazyJIT(std::unique_ptr<TargetMachine> TM, const DataLayout &DL,
> - LLVMContext &Context, CallbackManagerBuilder &BuildCallbackMgr)
> - : DL(DL), TM(std::move(TM)), ObjectLayer(),
> - CompileLayer(ObjectLayer, orc::SimpleCompiler(*this->TM)),
> - IRDumpLayer(CompileLayer, createDebugDumper()),
> - CCMgr(BuildCallbackMgr(IRDumpLayer, CCMgrMemMgr, Context)),
> - CODLayer(IRDumpLayer, *CCMgr, false),
> - CXXRuntimeOverrides(
> - [this](const std::string &S) { return mangle(S); }) {}
> + OrcLazyJIT(std::unique_ptr<TargetMachine> TM, LLVMContext &Context,
> + CallbackManagerBuilder &BuildCallbackMgr)
> + : TM(std::move(TM)),
> + ObjectLayer(),
> + CompileLayer(ObjectLayer, orc::SimpleCompiler(*this->TM)),
> + IRDumpLayer(CompileLayer, createDebugDumper()),
> + CCMgr(BuildCallbackMgr(IRDumpLayer, CCMgrMemMgr, Context)),
> + CODLayer(IRDumpLayer, *CCMgr, false),
> + CXXRuntimeOverrides([this](const std::string &S) { return mangle(S); }) {}
>
> ~OrcLazyJIT() {
> // Run any destructors registered with __cxa_atexit.
> @@ -74,7 +73,7 @@ public:
> ModuleHandleT addModule(std::unique_ptr<Module> M) {
> // Attach a data-layout if one isn't already present.
> if (M->getDataLayout().isDefault())
> - M->setDataLayout(DL);
> + M->setDataLayout(*TM->getDataLayout());
>
> // Record the static constructors and destructors. We have to do this before
> // we hand over ownership of the module to the JIT.
> @@ -132,11 +131,12 @@ public:
> }
>
> private:
> +
> std::string mangle(const std::string &Name) {
> std::string MangledName;
> {
> raw_string_ostream MangledNameStream(MangledName);
> - Mangler::getNameWithPrefix(MangledNameStream, Name, DL);
> + Mangler::getNameWithPrefix(MangledNameStream, Name, *TM->getDataLayout());
> }
> return MangledName;
> }
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list