X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=blobdiff_plain;f=include%2Fllvm%2FExecutionEngine%2FOrc%2FCompileOnDemandLayer.h;h=07914e386ad213f311231a59e8b7eecfb5ed3613;hp=ce5aa8fe07fd7ea51d1dd7be777d5472c6d784b7;hb=0b6b9ceae3f1ea6b29769fa7d2a461d65ee301c5;hpb=e8e35e60d80750e4f3faab2e9602b2fe86ea56d8 diff --git a/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h b/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h index ce5aa8fe07f..07914e386ad 100644 --- a/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h +++ b/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h @@ -246,10 +246,9 @@ private: StubInits[mangle(F.getName(), DL)] = std::make_pair(CCInfo.getAddress(), JITSymbolBase::flagsFromGlobalValue(F)); - CCInfo.setCompileAction( - [this, &LD, LMH, &F]() { - return this->extractAndCompile(LD, LMH, F); - }); + CCInfo.setCompileAction([this, &LD, LMH, &F]() { + return this->extractAndCompile(LD, LMH, F); + }); } LMResources.StubsMgr = CreateIndirectStubsManager(); @@ -339,10 +338,7 @@ private: static std::string mangle(StringRef Name, const DataLayout &DL) { std::string MangledName; - { - raw_string_ostream MangledNameStream(MangledName); - Mangler::getNameWithPrefix(MangledNameStream, Name, DL); - } + Mangler::getNameWithPrefix(raw_string_ostream(MangledName), Name, DL); return MangledName; } @@ -401,42 +397,42 @@ private: M->setDataLayout(SrcM.getDataLayout()); ValueToValueMapTy VMap; - auto Materializer = createLambdaMaterializer( - [this, &LMResources, &M, &VMap](Value *V) -> Value* { - if (auto *GV = dyn_cast(V)) { - return cloneGlobalVariableDecl(*M, *GV); - } else if (auto *F = dyn_cast(V)) { - // Check whether we want to clone an available_externally definition. - if (LMResources.StubsToClone.count(F)) { - // Ok - we want an inlinable stub. For that to work we need a decl - // for the stub pointer. - auto *StubPtr = createImplPointer(*F->getType(), *M, - F->getName() + "$stub_ptr", - nullptr); - auto *ClonedF = cloneFunctionDecl(*M, *F); - makeStub(*ClonedF, *StubPtr); - ClonedF->setLinkage(GlobalValue::AvailableExternallyLinkage); - ClonedF->addFnAttr(Attribute::AlwaysInline); - return ClonedF; - } + auto Materializer = createLambdaMaterializer([this, &LMResources, &M, + &VMap](Value *V) -> Value * { + if (auto *GV = dyn_cast(V)) + return cloneGlobalVariableDecl(*M, *GV); + if (auto *F = dyn_cast(V)) { + // Check whether we want to clone an available_externally definition. + if (!LMResources.StubsToClone.count(F)) return cloneFunctionDecl(*M, *F); - } else if (auto *A = dyn_cast(V)) { - auto *PTy = cast(A->getType()); - if (PTy->getElementType()->isFunctionTy()) - return Function::Create(cast(PTy->getElementType()), - GlobalValue::ExternalLinkage, - A->getName(), M.get()); - // else - return new GlobalVariable(*M, PTy->getElementType(), false, - GlobalValue::ExternalLinkage, - nullptr, A->getName(), nullptr, - GlobalValue::NotThreadLocal, - PTy->getAddressSpace()); - } - // Else. - return nullptr; - }); + + // Ok - we want an inlinable stub. For that to work we need a decl + // for the stub pointer. + auto *StubPtr = createImplPointer(*F->getType(), *M, + F->getName() + "$stub_ptr", nullptr); + auto *ClonedF = cloneFunctionDecl(*M, *F); + makeStub(*ClonedF, *StubPtr); + ClonedF->setLinkage(GlobalValue::AvailableExternallyLinkage); + ClonedF->addFnAttr(Attribute::AlwaysInline); + return ClonedF; + } + + if (auto *A = dyn_cast(V)) { + auto *Ty = A->getValueType(); + if (Ty->isFunctionTy()) + return Function::Create(cast(Ty), + GlobalValue::ExternalLinkage, A->getName(), + M.get()); + + return new GlobalVariable(*M, Ty, false, GlobalValue::ExternalLinkage, + nullptr, A->getName(), nullptr, + GlobalValue::NotThreadLocal, + A->getType()->getAddressSpace()); + } + + return nullptr; + }); // Create decls in the new module. for (auto *F : Part)