[llvm] r251853 - Orc: Drop some else-after-return, reflow a few spots, and avoid use of pointee types
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 2 15:09:38 PST 2015
Author: dblaikie
Date: Mon Nov 2 17:09:38 2015
New Revision: 251853
URL: http://llvm.org/viewvc/llvm-project?rev=251853&view=rev
Log:
Orc: Drop some else-after-return, reflow a few spots, and avoid use of pointee types
Modified:
llvm/trunk/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h
Modified: llvm/trunk/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h?rev=251853&r1=251852&r2=251853&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h (original)
+++ llvm/trunk/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h Mon Nov 2 17:09:38 2015
@@ -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<GlobalVariable>(V)) {
- return cloneGlobalVariableDecl(*M, *GV);
- } else if (auto *F = dyn_cast<Function>(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<GlobalVariable>(V))
+ return cloneGlobalVariableDecl(*M, *GV);
+
+ if (auto *F = dyn_cast<Function>(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<GlobalAlias>(V)) {
- auto *PTy = cast<PointerType>(A->getType());
- if (PTy->getElementType()->isFunctionTy())
- return Function::Create(cast<FunctionType>(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<GlobalAlias>(V)) {
+ auto *Ty = A->getValueType();
+ if (Ty->isFunctionTy())
+ return Function::Create(cast<FunctionType>(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)
More information about the llvm-commits
mailing list