[lld] r325185 - [WebAssebmly] Remove use of Optional to fix assertion in gcc
Sam Clegg via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 14 14:55:38 PST 2018
Author: sbc
Date: Wed Feb 14 14:55:38 2018
New Revision: 325185
URL: http://llvm.org/viewvc/llvm-project?rev=325185&view=rev
Log:
[WebAssebmly] Remove use of Optional to fix assertion in gcc
This was causing GCC builds with fail with:
Symbols.h:240:3: error: static assertion failed: Symbol types must be
trivially destructible
static_assert(std::is_trivially_destructible<T>(
The reason this is a gcc-only failure is that OptionalStorage has
as specialization for POD types that isn't built under GCC.
Differential Revision: https://reviews.llvm.org/D43317
Modified:
lld/trunk/wasm/Symbols.cpp
lld/trunk/wasm/Symbols.h
Modified: lld/trunk/wasm/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/Symbols.cpp?rev=325185&r1=325184&r2=325185&view=diff
==============================================================================
--- lld/trunk/wasm/Symbols.cpp (original)
+++ lld/trunk/wasm/Symbols.cpp Wed Feb 14 14:55:38 2018
@@ -31,19 +31,20 @@ DefinedGlobal *WasmSym::StackPointer;
bool Symbol::hasOutputIndex() const {
if (auto *F = dyn_cast_or_null<InputFunction>(Chunk))
return F->hasOutputIndex();
- return OutputIndex.hasValue();
+ return OutputIndex != INVALID_INDEX;
}
uint32_t Symbol::getOutputIndex() const {
if (auto *F = dyn_cast_or_null<InputFunction>(Chunk))
return F->getOutputIndex();
- return OutputIndex.getValue();
+ assert(OutputIndex != INVALID_INDEX);
+ return OutputIndex;
}
void Symbol::setOutputIndex(uint32_t Index) {
DEBUG(dbgs() << "setOutputIndex " << Name << " -> " << Index << "\n");
assert(!dyn_cast_or_null<InputFunction>(Chunk));
- assert(!OutputIndex.hasValue());
+ assert(OutputIndex == INVALID_INDEX);
OutputIndex = Index;
}
@@ -85,13 +86,14 @@ void FunctionSymbol::setFunctionType(con
uint32_t FunctionSymbol::getTableIndex() const {
if (auto *F = dyn_cast_or_null<InputFunction>(Chunk))
return F->getTableIndex();
- return TableIndex.getValue();
+ assert(TableIndex != INVALID_INDEX);
+ return TableIndex;
}
bool FunctionSymbol::hasTableIndex() const {
if (auto *F = dyn_cast_or_null<InputFunction>(Chunk))
return F->hasTableIndex();
- return TableIndex.hasValue();
+ return TableIndex != INVALID_INDEX;
}
void FunctionSymbol::setTableIndex(uint32_t Index) {
@@ -103,7 +105,7 @@ void FunctionSymbol::setTableIndex(uint3
return;
}
DEBUG(dbgs() << "setTableIndex " << Name << " -> " << Index << "\n");
- assert(!TableIndex.hasValue());
+ assert(TableIndex == INVALID_INDEX);
TableIndex = Index;
}
Modified: lld/trunk/wasm/Symbols.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/Symbols.h?rev=325185&r1=325184&r2=325185&view=diff
==============================================================================
--- lld/trunk/wasm/Symbols.h (original)
+++ lld/trunk/wasm/Symbols.h Wed Feb 14 14:55:38 2018
@@ -23,6 +23,8 @@ namespace wasm {
class InputFile;
class InputChunk;
+#define INVALID_INDEX UINT32_MAX
+
// The base class for real symbol classes.
class Symbol {
public:
@@ -82,7 +84,7 @@ protected:
uint32_t Flags;
InputFile *File;
InputChunk *Chunk;
- llvm::Optional<uint32_t> OutputIndex;
+ uint32_t OutputIndex = INVALID_INDEX;
};
class FunctionSymbol : public Symbol {
@@ -110,7 +112,7 @@ protected:
InputChunk *C)
: Symbol(Name, K, Flags, F, C) {}
- llvm::Optional<uint32_t> TableIndex;
+ uint32_t TableIndex = INVALID_INDEX;
// Explict function type, needed for undefined or synthetic functions only.
const WasmSignature *FunctionType = nullptr;
@@ -237,6 +239,8 @@ union SymbolUnion {
template <typename T, typename... ArgT>
T *replaceSymbol(Symbol *S, ArgT &&... Arg) {
+ static_assert(std::is_trivially_destructible<T>(),
+ "Symbol types must be trivially destructible");
static_assert(sizeof(T) <= sizeof(SymbolUnion), "Symbol too small");
static_assert(alignof(T) <= alignof(SymbolUnion),
"SymbolUnion not aligned enough");
More information about the llvm-commits
mailing list