summaryrefslogtreecommitdiff
path: root/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp')
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp16
1 files changed, 5 insertions, 11 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
index e3af6b2662ef..bf326e5106be 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
@@ -181,17 +181,11 @@ void WebAssemblyAsmPrinter::emitGlobalVariable(const GlobalVariable *GV) {
if (!Sym->getType()) {
const WebAssemblyTargetLowering &TLI = *Subtarget->getTargetLowering();
- SmallVector<EVT, 1> VTs;
- ComputeValueVTs(TLI, GV->getParent()->getDataLayout(), GV->getValueType(),
- VTs);
- if (VTs.size() != 1 ||
- TLI.getNumRegisters(GV->getParent()->getContext(), VTs[0]) != 1)
- report_fatal_error("Aggregate globals not yet implemented");
- MVT VT = TLI.getRegisterType(GV->getParent()->getContext(), VTs[0]);
- bool Mutable = true;
- wasm::ValType Type = WebAssembly::toValType(VT);
- Sym->setType(wasm::WASM_SYMBOL_TYPE_GLOBAL);
- Sym->setGlobalType(wasm::WasmGlobalType{uint8_t(Type), Mutable});
+ SmallVector<MVT, 1> VTs;
+ Type *GlobalVT = GV->getValueType();
+ computeLegalValueVTs(TLI, GV->getParent()->getContext(),
+ GV->getParent()->getDataLayout(), GlobalVT, VTs);
+ WebAssembly::wasmSymbolSetType(Sym, GlobalVT, VTs);
}
// If the GlobalVariable refers to a table, we handle it here instead of