aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDan Gohman <sunfish@mozilla.com>2014-03-04 21:11:46 -0800
committerDan Gohman <sunfish@mozilla.com>2014-03-04 21:17:53 -0800
commit854f1819257136903814ed8b149dea96967c38da (patch)
tree3cf2c89a84c93afc6900f9631683caf8b0990529 /lib
parent5ff3664fbfebff6fa2f364d3ef7aa51a931d4e31 (diff)
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/Target/JSBackend/JSBackend.cpp35
1 files 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<Function>(val) || isa<Constant>(val)) {
- name = val->getName().str();
- sanitizeGlobal(name);
- } else {
- name = val->getName().str();
- sanitizeLocal(name);
- }
+ name = val->getName().str();
+ } else {
+ name = utostr(UniqueNum++);
+ }
+
+ if (isa<Constant>(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();