accept empty EM_ASMs
diff --git a/lib/Target/JSBackend/JSBackend.cpp b/lib/Target/JSBackend/JSBackend.cpp index 6693eb2..1293384 100644 --- a/lib/Target/JSBackend/JSBackend.cpp +++ b/lib/Target/JSBackend/JSBackend.cpp
@@ -371,19 +371,24 @@ unsigned getAsmConstId(const Value *V) { V = resolveFully(V); const Constant *CI = cast<GlobalVariable>(V)->getInitializer(); - const ConstantDataSequential *CDS = cast<ConstantDataSequential>(CI); - std::string code = CDS->getAsString(); - // replace newlines quotes with escaped newlines - size_t curr = 0; - while ((curr = code.find("\\n", curr)) != std::string::npos) { - code = code.replace(curr, 2, "\\\\n"); - curr += 3; // skip this one - } - // replace double quotes with escaped single quotes - curr = 0; - while ((curr = code.find('"', curr)) != std::string::npos) { - code = code.replace(curr, 1, "\\" "\""); - curr += 2; // skip this one + std::string code; + if (isa<ConstantAggregateZero>(CI)) { + code = " "; + } else { + const ConstantDataSequential *CDS = cast<ConstantDataSequential>(CI); + code = CDS->getAsString(); + // replace newlines quotes with escaped newlines + size_t curr = 0; + while ((curr = code.find("\\n", curr)) != std::string::npos) { + code = code.replace(curr, 2, "\\\\n"); + curr += 3; // skip this one + } + // replace double quotes with escaped single quotes + curr = 0; + while ((curr = code.find('"', curr)) != std::string::npos) { + code = code.replace(curr, 1, "\\" "\""); + curr += 2; // skip this one + } } if (AsmConsts.count(code) > 0) return AsmConsts[code]; unsigned id = AsmConsts.size();