[lld] 757d9d2 - [lld] Use value_or instead of getValueOr (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 19 00:29:48 PDT 2022
Author: Kazu Hirata
Date: 2022-06-19T00:29:41-07:00
New Revision: 757d9d22cd9100e28d7e885a106945afd08f9e24
URL: https://github.com/llvm/llvm-project/commit/757d9d22cd9100e28d7e885a106945afd08f9e24
DIFF: https://github.com/llvm/llvm-project/commit/757d9d22cd9100e28d7e885a106945afd08f9e24.diff
LOG: [lld] Use value_or instead of getValueOr (NFC)
Added:
Modified:
lld/ELF/LinkerScript.cpp
lld/MachO/Config.h
lld/wasm/Driver.cpp
lld/wasm/InputChunks.cpp
lld/wasm/InputElement.h
lld/wasm/InputFiles.cpp
lld/wasm/OutputSections.cpp
lld/wasm/SyntheticSections.cpp
lld/wasm/Writer.cpp
Removed:
################################################################################
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index 911d6dfbe113d..0f4c908efdd20 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -1295,7 +1295,7 @@ const Defined *LinkerScript::assignAddresses() {
if (script->hasSectionsCommand) {
// With a linker script, assignment of addresses to headers is covered by
// allocateHeaders().
- dot = config->imageBase.getValueOr(0);
+ dot = config->imageBase.value_or(0);
} else {
// Assign addresses to headers right now.
dot = target->getImageBase();
@@ -1331,7 +1331,7 @@ SmallVector<PhdrEntry *, 0> LinkerScript::createPhdrs() {
// Process PHDRS and FILEHDR keywords because they are not
// real output sections and cannot be added in the following loop.
for (const PhdrsCommand &cmd : phdrsCommands) {
- PhdrEntry *phdr = make<PhdrEntry>(cmd.type, cmd.flags.getValueOr(PF_R));
+ PhdrEntry *phdr = make<PhdrEntry>(cmd.type, cmd.flags.value_or(PF_R));
if (cmd.hasFilehdr)
phdr->add(Out::elfHeader);
diff --git a/lld/MachO/Config.h b/lld/MachO/Config.h
index 87fdbf092012d..206509c3df83f 100644
--- a/lld/MachO/Config.h
+++ b/lld/MachO/Config.h
@@ -43,8 +43,8 @@ struct PlatformInfo {
inline uint32_t encodeVersion(const llvm::VersionTuple &version) {
return ((version.getMajor() << 020) |
- (version.getMinor().getValueOr(0) << 010) |
- version.getSubminor().getValueOr(0));
+ (version.getMinor().value_or(0) << 010) |
+ version.getSubminor().value_or(0));
}
enum class NamespaceKind {
diff --git a/lld/wasm/Driver.cpp b/lld/wasm/Driver.cpp
index ca32d9a49da0b..3764c921ff45f 100644
--- a/lld/wasm/Driver.cpp
+++ b/lld/wasm/Driver.cpp
@@ -581,7 +581,7 @@ createUndefinedGlobal(StringRef name, llvm::wasm::WasmGlobalType *type) {
static InputGlobal *createGlobal(StringRef name, bool isMutable) {
llvm::wasm::WasmGlobal wasmGlobal;
- bool is64 = config->is64.getValueOr(false);
+ bool is64 = config->is64.value_or(false);
wasmGlobal.Type = {uint8_t(is64 ? WASM_TYPE_I64 : WASM_TYPE_I32), isMutable};
wasmGlobal.InitExpr = intConst(0, is64);
wasmGlobal.SymbolName = name;
@@ -616,11 +616,11 @@ static void createSyntheticSymbols() {
"__wasm_call_ctors", WASM_SYMBOL_VISIBILITY_HIDDEN,
make<SyntheticFunction>(nullSignature, "__wasm_call_ctors"));
- bool is64 = config->is64.getValueOr(false);
+ bool is64 = config->is64.value_or(false);
if (config->isPic) {
WasmSym::stackPointer =
- createUndefinedGlobal("__stack_pointer", config->is64.getValueOr(false)
+ createUndefinedGlobal("__stack_pointer", config->is64.value_or(false)
? &mutableGlobalTypeI64
: &mutableGlobalTypeI32);
// For PIC code, we import two global variables (__memory_base and
@@ -672,7 +672,7 @@ static void createOptionalSymbols() {
WasmSym::heapBase = symtab->addOptionalDataSymbol("__heap_base");
WasmSym::definedMemoryBase = symtab->addOptionalDataSymbol("__memory_base");
WasmSym::definedTableBase = symtab->addOptionalDataSymbol("__table_base");
- if (config->is64.getValueOr(false))
+ if (config->is64.value_or(false))
WasmSym::definedTableBase32 =
symtab->addOptionalDataSymbol("__table_base32");
}
diff --git a/lld/wasm/InputChunks.cpp b/lld/wasm/InputChunks.cpp
index 34560ce9ca0f8..53b5288801d86 100644
--- a/lld/wasm/InputChunks.cpp
+++ b/lld/wasm/InputChunks.cpp
@@ -364,7 +364,7 @@ void InputChunk::generateRelocationCode(raw_ostream &os) const {
LLVM_DEBUG(dbgs() << "generating runtime relocations: " << name
<< " count=" << relocations.size() << "\n");
- bool is64 = config->is64.getValueOr(false);
+ bool is64 = config->is64.value_or(false);
unsigned opcode_ptr_const = is64 ? WASM_OPCODE_I64_CONST
: WASM_OPCODE_I32_CONST;
unsigned opcode_ptr_add = is64 ? WASM_OPCODE_I64_ADD
diff --git a/lld/wasm/InputElement.h b/lld/wasm/InputElement.h
index 6c8f41db0290a..9bea90b87640c 100644
--- a/lld/wasm/InputElement.h
+++ b/lld/wasm/InputElement.h
@@ -64,7 +64,7 @@ class InputGlobal : public InputElement {
const WasmInitExpr &getInitExpr() const { return initExpr; }
void setPointerValue(uint64_t value) {
- initExpr = intConst(value, config->is64.getValueOr(false));
+ initExpr = intConst(value, config->is64.value_or(false));
}
private:
diff --git a/lld/wasm/InputFiles.cpp b/lld/wasm/InputFiles.cpp
index f6f35376ec424..04ec342fe5422 100644
--- a/lld/wasm/InputFiles.cpp
+++ b/lld/wasm/InputFiles.cpp
@@ -47,7 +47,7 @@ void InputFile::checkArch(Triple::ArchType arch) const {
if (is64 && !config->is64.hasValue()) {
fatal(toString(this) +
": must specify -mwasm64 to process wasm64 object files");
- } else if (config->is64.getValueOr(false) != is64) {
+ } else if (config->is64.value_or(false) != is64) {
fatal(toString(this) +
": wasm32 object file can't be linked in wasm64 mode");
}
diff --git a/lld/wasm/OutputSections.cpp b/lld/wasm/OutputSections.cpp
index f7e4df8900a21..3e844ecff09b1 100644
--- a/lld/wasm/OutputSections.cpp
+++ b/lld/wasm/OutputSections.cpp
@@ -115,7 +115,7 @@ void DataSection::finalizeContents() {
writeUleb128(os, segmentCount, "data segment count");
os.flush();
bodySize = dataSectionHeader.size();
- bool is64 = config->is64.getValueOr(false);
+ bool is64 = config->is64.value_or(false);
for (OutputSegment *segment : segments) {
if (!segment->requiredInBinary())
diff --git a/lld/wasm/SyntheticSections.cpp b/lld/wasm/SyntheticSections.cpp
index 2d8fb0de6489e..1149e206b6b00 100644
--- a/lld/wasm/SyntheticSections.cpp
+++ b/lld/wasm/SyntheticSections.cpp
@@ -124,8 +124,8 @@ void DylinkSection::writeBody() {
for (const Symbol *sym : importInfo) {
LLVM_DEBUG(llvm::dbgs() << "imports info: " << toString(*sym) << "\n");
- StringRef module = sym->importModule.getValueOr(defaultModule);
- StringRef name = sym->importName.getValueOr(sym->getName());
+ StringRef module = sym->importModule.value_or(defaultModule);
+ StringRef name = sym->importName.value_or(sym->getName());
writeStr(sub.os, module, "import module");
writeStr(sub.os, name, "import name");
writeUleb128(sub.os, sym->flags, "sym flags");
@@ -184,8 +184,8 @@ void ImportSection::addGOTEntry(Symbol *sym) {
void ImportSection::addImport(Symbol *sym) {
assert(!isSealed);
- StringRef module = sym->importModule.getValueOr(defaultModule);
- StringRef name = sym->importName.getValueOr(sym->getName());
+ StringRef module = sym->importModule.value_or(defaultModule);
+ StringRef name = sym->importName.value_or(sym->getName());
if (auto *f = dyn_cast<FunctionSymbol>(sym)) {
ImportKey<WasmSignature> key(*(f->getSignature()), module, name);
auto entry = importedFunctions.try_emplace(key, numImportedFunctions);
@@ -232,7 +232,7 @@ void ImportSection::writeBody() {
writeUleb128(os, getNumImports(), "import count");
- bool is64 = config->is64.getValueOr(false);
+ bool is64 = config->is64.value_or(false);
if (config->importMemory) {
WasmImport import;
@@ -254,8 +254,8 @@ void ImportSection::writeBody() {
for (const Symbol *sym : importedSymbols) {
WasmImport import;
- import.Field = sym->importName.getValueOr(sym->getName());
- import.Module = sym->importModule.getValueOr(defaultModule);
+ import.Field = sym->importName.value_or(sym->getName());
+ import.Module = sym->importModule.value_or(defaultModule);
if (auto *functionSym = dyn_cast<FunctionSymbol>(sym)) {
import.Kind = WASM_EXTERNAL_FUNCTION;
@@ -357,7 +357,7 @@ void MemorySection::writeBody() {
flags |= WASM_LIMITS_FLAG_HAS_MAX;
if (config->sharedMemory)
flags |= WASM_LIMITS_FLAG_IS_SHARED;
- if (config->is64.getValueOr(false))
+ if (config->is64.value_or(false))
flags |= WASM_LIMITS_FLAG_IS_64;
writeUleb128(os, flags, "memory limits flags");
writeUleb128(os, numMemoryPages, "initial pages");
@@ -415,7 +415,7 @@ void GlobalSection::addInternalGOTEntry(Symbol *sym) {
void GlobalSection::generateRelocationCode(raw_ostream &os, bool TLS) const {
assert(!config->extendedConst);
- bool is64 = config->is64.getValueOr(false);
+ bool is64 = config->is64.value_or(false);
unsigned opcode_ptr_const = is64 ? WASM_OPCODE_I64_CONST
: WASM_OPCODE_I32_CONST;
unsigned opcode_ptr_add = is64 ? WASM_OPCODE_I64_ADD
@@ -465,7 +465,7 @@ void GlobalSection::writeBody() {
writeGlobalType(os, g->getType());
writeInitExpr(os, g->getInitExpr());
}
- bool is64 = config->is64.getValueOr(false);
+ bool is64 = config->is64.value_or(false);
uint8_t itype = is64 ? WASM_TYPE_I64 : WASM_TYPE_I32;
for (const Symbol *sym : internalGotSymbols) {
bool mutable_ = false;
@@ -569,8 +569,8 @@ void ElemSection::writeBody() {
if (config->isPic) {
initExpr.Inst.Opcode = WASM_OPCODE_GLOBAL_GET;
initExpr.Inst.Value.Global =
- (config->is64.getValueOr(false) ? WasmSym::tableBase32
- : WasmSym::tableBase)
+ (config->is64.value_or(false) ? WasmSym::tableBase32
+ : WasmSym::tableBase)
->getGlobalIndex();
} else {
initExpr.Inst.Opcode = WASM_OPCODE_I32_CONST;
diff --git a/lld/wasm/Writer.cpp b/lld/wasm/Writer.cpp
index c9307d73ecaf5..3f9797ec5b343 100644
--- a/lld/wasm/Writer.cpp
+++ b/lld/wasm/Writer.cpp
@@ -328,8 +328,7 @@ void Writer::layoutMemory() {
WasmSym::heapBase->setVA(memoryPtr);
}
- uint64_t maxMemorySetting = 1ULL
- << (config->is64.getValueOr(false) ? 48 : 32);
+ uint64_t maxMemorySetting = 1ULL << (config->is64.value_or(false) ? 48 : 32);
if (config->initialMemory != 0) {
if (config->initialMemory != alignTo(config->initialMemory, WasmPageSize))
@@ -1057,7 +1056,7 @@ void Writer::createInitMemoryFunction() {
assert(WasmSym::initMemoryFlag);
flagAddress = WasmSym::initMemoryFlag->getVA();
}
- bool is64 = config->is64.getValueOr(false);
+ bool is64 = config->is64.value_or(false);
std::string bodyContent;
{
raw_string_ostream os(bodyContent);
More information about the llvm-commits
mailing list