aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/ExecutionEngine
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2020-01-28 20:23:46 +0100
committerBenjamin Kramer <benny.kra@googlemail.com>2020-01-28 23:25:25 +0100
commitadcd02683856c30ba6f349279509acecd90063df (patch)
tree7b5927ef2ecab1618842183fac5ebe848f5832dd /llvm/lib/ExecutionEngine
parent5eaf44f99f0a0a3bdfa892892b8aaca841c8dbe0 (diff)
downloadllvm-adcd02683856c30ba6f349279509acecd90063df.zip
llvm-adcd02683856c30ba6f349279509acecd90063df.tar.gz
llvm-adcd02683856c30ba6f349279509acecd90063df.tar.bz2
Make llvm::StringRef to std::string conversions explicit.
This is how it should've been and brings it more in line with std::string_view. There should be no functional change here. This is mostly mechanical from a custom clang-tidy check, with a lot of manual fixups. It uncovers a lot of minor inefficiencies. This doesn't actually modify StringRef yet, I'll do that in a follow-up.
Diffstat (limited to 'llvm/lib/ExecutionEngine')
-rw-r--r--llvm/lib/ExecutionEngine/ExecutionEngine.cpp26
-rw-r--r--llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp4
-rw-r--r--llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp4
-rw-r--r--llvm/lib/ExecutionEngine/Orc/CompileOnDemandLayer.cpp2
-rw-r--r--llvm/lib/ExecutionEngine/Orc/Core.cpp4
-rw-r--r--llvm/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp2
-rw-r--r--llvm/lib/ExecutionEngine/Orc/OrcCBindingsStack.h4
-rw-r--r--llvm/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h9
-rw-r--r--llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h2
9 files changed, 29 insertions, 28 deletions
diff --git a/llvm/lib/ExecutionEngine/ExecutionEngine.cpp b/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
index ee7a7cb..77f9d70 100644
--- a/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
+++ b/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
@@ -200,7 +200,7 @@ std::string ExecutionEngine::getMangledName(const GlobalValue *GV) {
: GV->getParent()->getDataLayout();
Mangler::getNameWithPrefix(FullName, GV->getName(), DL);
- return FullName.str();
+ return std::string(FullName.str());
}
void ExecutionEngine::addGlobalMapping(const GlobalValue *GV, void *Addr) {
@@ -223,7 +223,7 @@ void ExecutionEngine::addGlobalMapping(StringRef Name, uint64_t Addr) {
std::string &V = EEState.getGlobalAddressReverseMap()[CurVal];
assert((!V.empty() || !Name.empty()) &&
"GlobalMapping already established!");
- V = Name;
+ V = std::string(Name);
}
}
@@ -269,7 +269,7 @@ uint64_t ExecutionEngine::updateGlobalMapping(StringRef Name, uint64_t Addr) {
std::string &V = EEState.getGlobalAddressReverseMap()[CurVal];
assert((!V.empty() || !Name.empty()) &&
"GlobalMapping already established!");
- V = Name;
+ V = std::string(Name);
}
return OldVal;
}
@@ -1200,8 +1200,8 @@ void ExecutionEngine::emitGlobals() {
GV.hasAppendingLinkage() || !GV.hasName())
continue;// Ignore external globals and globals with internal linkage.
- const GlobalValue *&GVEntry =
- LinkedGlobalsMap[std::make_pair(GV.getName(), GV.getType())];
+ const GlobalValue *&GVEntry = LinkedGlobalsMap[std::make_pair(
+ std::string(GV.getName()), GV.getType())];
// If this is the first time we've seen this global, it is the canonical
// version.
@@ -1228,8 +1228,8 @@ void ExecutionEngine::emitGlobals() {
for (const auto &GV : M.globals()) {
// In the multi-module case, see what this global maps to.
if (!LinkedGlobalsMap.empty()) {
- if (const GlobalValue *GVEntry =
- LinkedGlobalsMap[std::make_pair(GV.getName(), GV.getType())]) {
+ if (const GlobalValue *GVEntry = LinkedGlobalsMap[std::make_pair(
+ std::string(GV.getName()), GV.getType())]) {
// If something else is the canonical global, ignore this one.
if (GVEntry != &GV) {
NonCanonicalGlobals.push_back(&GV);
@@ -1243,8 +1243,8 @@ void ExecutionEngine::emitGlobals() {
} else {
// External variable reference. Try to use the dynamic loader to
// get a pointer to it.
- if (void *SymAddr =
- sys::DynamicLibrary::SearchForAddressOfSymbol(GV.getName()))
+ if (void *SymAddr = sys::DynamicLibrary::SearchForAddressOfSymbol(
+ std::string(GV.getName())))
addGlobalMapping(&GV, SymAddr);
else {
report_fatal_error("Could not resolve external global address: "
@@ -1258,8 +1258,8 @@ void ExecutionEngine::emitGlobals() {
if (!NonCanonicalGlobals.empty()) {
for (unsigned i = 0, e = NonCanonicalGlobals.size(); i != e; ++i) {
const GlobalValue *GV = NonCanonicalGlobals[i];
- const GlobalValue *CGV =
- LinkedGlobalsMap[std::make_pair(GV->getName(), GV->getType())];
+ const GlobalValue *CGV = LinkedGlobalsMap[std::make_pair(
+ std::string(GV->getName()), GV->getType())];
void *Ptr = getPointerToGlobalIfAvailable(CGV);
assert(Ptr && "Canonical global wasn't codegen'd!");
addGlobalMapping(GV, Ptr);
@@ -1271,8 +1271,8 @@ void ExecutionEngine::emitGlobals() {
for (const auto &GV : M.globals()) {
if (!GV.isDeclaration()) {
if (!LinkedGlobalsMap.empty()) {
- if (const GlobalValue *GVEntry =
- LinkedGlobalsMap[std::make_pair(GV.getName(), GV.getType())])
+ if (const GlobalValue *GVEntry = LinkedGlobalsMap[std::make_pair(
+ std::string(GV.getName()), GV.getType())])
if (GVEntry != &GV) // Not the canonical variable.
continue;
}
diff --git a/llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp b/llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp
index 701f108..89eef578 100644
--- a/llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp
@@ -47,8 +47,8 @@ Expected<std::unique_ptr<LinkGraph>> MachOLinkGraphBuilder::buildGraph() {
MachOLinkGraphBuilder::MachOLinkGraphBuilder(const object::MachOObjectFile &Obj)
: Obj(Obj),
- G(std::make_unique<LinkGraph>(Obj.getFileName(), getPointerSize(Obj),
- getEndianness(Obj))) {}
+ G(std::make_unique<LinkGraph>(std::string(Obj.getFileName()),
+ getPointerSize(Obj), getEndianness(Obj))) {}
void MachOLinkGraphBuilder::addCustomSectionParser(
StringRef SectionName, SectionParserFunction Parser) {
diff --git a/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp b/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
index 94741f5..9c3d0d5 100644
--- a/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
+++ b/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
@@ -609,7 +609,7 @@ GenericValue MCJIT::runFunction(Function *F, ArrayRef<GenericValue> ArgValues) {
void *MCJIT::getPointerToNamedFunction(StringRef Name, bool AbortOnFailure) {
if (!isSymbolSearchingDisabled()) {
- if (auto Sym = Resolver.findSymbol(Name)) {
+ if (auto Sym = Resolver.findSymbol(std::string(Name))) {
if (auto AddrOrErr = Sym.getAddress())
return reinterpret_cast<void*>(
static_cast<uintptr_t>(*AddrOrErr));
@@ -619,7 +619,7 @@ void *MCJIT::getPointerToNamedFunction(StringRef Name, bool AbortOnFailure) {
/// If a LazyFunctionCreator is installed, use it to get/create the function.
if (LazyFunctionCreator)
- if (void *RP = LazyFunctionCreator(Name))
+ if (void *RP = LazyFunctionCreator(std::string(Name)))
return RP;
if (AbortOnFailure) {
diff --git a/llvm/lib/ExecutionEngine/Orc/CompileOnDemandLayer.cpp b/llvm/lib/ExecutionEngine/Orc/CompileOnDemandLayer.cpp
index 9c504da..29d18b6 100644
--- a/llvm/lib/ExecutionEngine/Orc/CompileOnDemandLayer.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/CompileOnDemandLayer.cpp
@@ -35,7 +35,7 @@ static ThreadSafeModule extractSubModule(ThreadSafeModule &TSM,
Constant *Aliasee = A.getAliasee();
assert(A.hasName() && "Anonymous alias?");
assert(Aliasee->hasName() && "Anonymous aliasee");
- std::string AliasName = A.getName();
+ std::string AliasName = std::string(A.getName());
if (isa<Function>(Aliasee)) {
auto *F = cloneFunctionDecl(*A.getParent(), *cast<Function>(Aliasee));
diff --git a/llvm/lib/ExecutionEngine/Orc/Core.cpp b/llvm/lib/ExecutionEngine/Orc/Core.cpp
index ec706cf..f2b161c 100644
--- a/llvm/lib/ExecutionEngine/Orc/Core.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/Core.cpp
@@ -838,7 +838,7 @@ JITDylib::defineMaterializing(SymbolFlagsMap SymbolFlags) {
Symbols.erase(SI);
// FIXME: Return all duplicates.
- return make_error<DuplicateDefinition>(*Name);
+ return make_error<DuplicateDefinition>(std::string(*Name));
}
// Otherwise just make a note to discard this symbol after the loop.
@@ -1815,7 +1815,7 @@ Error JITDylib::defineImpl(MaterializationUnit &MU) {
// If there were any duplicate definitions then bail out.
if (!Duplicates.empty())
- return make_error<DuplicateDefinition>(**Duplicates.begin());
+ return make_error<DuplicateDefinition>(std::string(**Duplicates.begin()));
// Discard any overridden defs in this MU.
for (auto &S : MUDefsOverridden)
diff --git a/llvm/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp b/llvm/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp
index 114e81e..3eda0fa 100644
--- a/llvm/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp
@@ -33,7 +33,7 @@ Expected<JITTargetMachineBuilder> JITTargetMachineBuilder::detectHost() {
for (auto &Feature : FeatureMap)
TMBuilder.getFeatures().AddFeature(Feature.first(), Feature.second);
- TMBuilder.setCPU(llvm::sys::getHostCPUName());
+ TMBuilder.setCPU(std::string(llvm::sys::getHostCPUName()));
return TMBuilder;
}
diff --git a/llvm/lib/ExecutionEngine/Orc/OrcCBindingsStack.h b/llvm/lib/ExecutionEngine/Orc/OrcCBindingsStack.h
index e0af3df..87bb439 100644
--- a/llvm/lib/ExecutionEngine/Orc/OrcCBindingsStack.h
+++ b/llvm/lib/ExecutionEngine/Orc/OrcCBindingsStack.h
@@ -133,7 +133,7 @@ private:
orc::SymbolNameSet Result;
for (auto &S : Symbols) {
- if (auto Sym = findSymbol(*S)) {
+ if (auto Sym = findSymbol(std::string(*S))) {
if (!Sym.getFlags().isStrong())
Result.insert(S);
} else if (auto Err = Sym.takeError()) {
@@ -151,7 +151,7 @@ private:
orc::SymbolNameSet UnresolvedSymbols;
for (auto &S : Symbols) {
- if (auto Sym = findSymbol(*S)) {
+ if (auto Sym = findSymbol(std::string(*S))) {
if (auto Addr = Sym.getAddress()) {
Query->notifySymbolMetRequiredState(
S, JITEvaluatedSymbol(*Addr, Sym.getFlags()));
diff --git a/llvm/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h b/llvm/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h
index 169dc8f..139572b 100644
--- a/llvm/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h
+++ b/llvm/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h
@@ -154,7 +154,8 @@ class OrcMCJITReplacement : public ExecutionEngine {
M.reportError(std::move(Err));
return SymbolNameSet();
} else {
- if (auto Sym2 = M.ClientResolver->findSymbolInLogicalDylib(*S)) {
+ if (auto Sym2 =
+ M.ClientResolver->findSymbolInLogicalDylib(std::string(*S))) {
if (!Sym2.getFlags().isStrong())
Result.insert(S);
} else if (auto Err = Sym2.takeError()) {
@@ -187,7 +188,7 @@ class OrcMCJITReplacement : public ExecutionEngine {
M.ES.legacyFailQuery(*Query, std::move(Err));
return SymbolNameSet();
} else {
- if (auto Sym2 = M.ClientResolver->findSymbol(*S)) {
+ if (auto Sym2 = M.ClientResolver->findSymbol(std::string(*S))) {
if (auto Addr = Sym2.getAddress()) {
Query->notifySymbolMetRequiredState(
S, JITEvaluatedSymbol(*Addr, Sym2.getFlags()));
@@ -378,9 +379,9 @@ public:
private:
JITSymbol findMangledSymbol(StringRef Name) {
- if (auto Sym = LazyEmitLayer.findSymbol(Name, false))
+ if (auto Sym = LazyEmitLayer.findSymbol(std::string(Name), false))
return Sym;
- if (auto Sym = ClientResolver->findSymbol(Name))
+ if (auto Sym = ClientResolver->findSymbol(std::string(Name)))
return Sym;
if (auto Sym = scanArchives(Name))
return Sym;
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h
index cec7b92..a2f6df3 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h
@@ -74,7 +74,7 @@ class SectionEntry {
public:
SectionEntry(StringRef name, uint8_t *address, size_t size,
size_t allocationSize, uintptr_t objAddress)
- : Name(name), Address(address), Size(size),
+ : Name(std::string(name)), Address(address), Size(size),
LoadAddress(reinterpret_cast<uintptr_t>(address)), StubOffset(size),
AllocationSize(allocationSize), ObjAddress(objAddress) {
// AllocationSize is used only in asserts, prevent an "unused private field"