From 854f1819257136903814ed8b149dea96967c38da Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Tue, 4 Mar 2014 21:11:46 -0800 Subject: Simplify the handling of unnamed values. This will also make it easier for the upcoming AllocaManager to eliminate allocas, because unnamed eliminated allocas won't be assigned names. --- lib/Target/JSBackend/JSBackend.cpp | 35 +++++++++-------------------------- 1 file changed, 9 insertions(+), 26 deletions(-) diff --git a/lib/Target/JSBackend/JSBackend.cpp b/lib/Target/JSBackend/JSBackend.cpp index b2ef5975cc..3f1fdd6fb8 100644 --- a/lib/Target/JSBackend/JSBackend.cpp +++ b/lib/Target/JSBackend/JSBackend.cpp @@ -575,16 +575,17 @@ const std::string &JSWriter::getJSName(const Value* val) { std::string name; if (val->hasName()) { - if (isa(val) || isa(val)) { - name = val->getName().str(); - sanitizeGlobal(name); - } else { - name = val->getName().str(); - sanitizeLocal(name); - } + name = val->getName().str(); + } else { + name = utostr(UniqueNum++); + } + + if (isa(val)) { + sanitizeGlobal(name); } else { - name = "u$" + utostr(UniqueNum++); + sanitizeLocal(name); } + return ValueNames[val] = name; } @@ -1823,24 +1824,6 @@ void JSWriter::processConstants() { void JSWriter::printFunction(const Function *F) { ValueNames.clear(); - // Ensure all arguments and locals are named (we assume used values need names, which might be false if the optimizer did not run) - unsigned Next = 1; - for (Function::const_arg_iterator AI = F->arg_begin(), AE = F->arg_end(); - AI != AE; ++AI) { - if (!AI->hasName() && !AI->use_empty()) { - ValueNames[AI] = "$" + utostr(Next++); - } - } - for (Function::const_iterator BI = F->begin(), BE = F->end(); - BI != BE; ++BI) { - for (BasicBlock::const_iterator II = BI->begin(), E = BI->end(); - II != E; ++II) { - if (!II->hasName() && !II->use_empty()) { - ValueNames[II] = "$" + utostr(Next++); - } - } - } - // Prepare and analyze function UsedVars.clear(); -- cgit v1.2.3-18-g5258