From 4eeec14d343793af27e77620e1e66eda522a8a6b Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Tue, 20 Mar 2018 17:51:02 -0400 Subject: add the highbits global to the IR (#1483) We were using the global to return 64-bit values from functions, but said global wasn't actually present in the IR. This omission caused the generated code to fail validation. --- src/passes/I64ToI32Lowering.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src') diff --git a/src/passes/I64ToI32Lowering.cpp b/src/passes/I64ToI32Lowering.cpp index a359d22d8..c77ec3963 100644 --- a/src/passes/I64ToI32Lowering.cpp +++ b/src/passes/I64ToI32Lowering.cpp @@ -109,6 +109,15 @@ struct I64ToI32Lowering : public WalkerPass> { high->name = makeHighName(curr->name); module->addGlobal(high); } + + // For functions that return 64-bit values, we use this global variable + // to return the high 32 bits. + auto* highBits = new Global(); + highBits->type = i32; + highBits->name = highBitsGlobal; + highBits->init = builder->makeConst(Literal(int32_t(0))); + highBits->mutable_ = true; + module->addGlobal(highBits); PostWalker::doWalkModule(module); } -- cgit v1.2.3