diff options
Diffstat (limited to 'src/passes/SafeHeap.cpp')
-rw-r--r-- | src/passes/SafeHeap.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/passes/SafeHeap.cpp b/src/passes/SafeHeap.cpp index ebaf42358..784bc761d 100644 --- a/src/passes/SafeHeap.cpp +++ b/src/passes/SafeHeap.cpp @@ -114,8 +114,9 @@ struct SafeHeap : public Pass { void addImports(Module* module) { // imports - dynamicTopPtr = ImportUtils::getImport(*module, ENV, DYNAMICTOP_PTR_IMPORT); - if (!dynamicTopPtr.is()) { + if (auto* existing = ImportUtils::getImport(*module, ENV, DYNAMICTOP_PTR_IMPORT)) { + dynamicTopPtr = existing->name; + } else { auto* import = new Import; import->name = dynamicTopPtr = DYNAMICTOP_PTR_IMPORT; import->module = ENV; @@ -124,8 +125,9 @@ struct SafeHeap : public Pass { import->globalType = i32; module->addImport(import); } - segfault = ImportUtils::getImport(*module, ENV, SEGFAULT_IMPORT); - if (!segfault.is()) { + if (auto* existing = ImportUtils::getImport(*module, ENV, SEGFAULT_IMPORT)) { + dynamicTopPtr = existing->name; + } else { auto* import = new Import; import->name = segfault = SEGFAULT_IMPORT; import->module = ENV; @@ -134,8 +136,9 @@ struct SafeHeap : public Pass { import->functionType = ensureFunctionType("v", module)->name; module->addImport(import); } - alignfault = ImportUtils::getImport(*module, ENV, ALIGNFAULT_IMPORT); - if (!alignfault.is()) { + if (auto* existing = ImportUtils::getImport(*module, ENV, ALIGNFAULT_IMPORT)) { + dynamicTopPtr = existing->name; + } else { auto* import = new Import; import->name = alignfault = ALIGNFAULT_IMPORT; import->module = ENV; |