[llvm-commits] CVS: llvm/tools/llvm-upgrade/UpgradeParser.y
Reid Spencer
reid at x10sys.com
Thu Feb 8 01:07:41 PST 2007
Changes in directory llvm/tools/llvm-upgrade:
UpgradeParser.y updated: 1.61 -> 1.62
---
Log message:
For PR1187: http://llvm.org/PR1187 :
Rename function scope names that conflict with basic block names.
---
Diffs of the changes: (+20 -11)
UpgradeParser.y | 31 ++++++++++++++++++++-----------
1 files changed, 20 insertions(+), 11 deletions(-)
Index: llvm/tools/llvm-upgrade/UpgradeParser.y
diff -u llvm/tools/llvm-upgrade/UpgradeParser.y:1.61 llvm/tools/llvm-upgrade/UpgradeParser.y:1.62
--- llvm/tools/llvm-upgrade/UpgradeParser.y:1.61 Thu Feb 8 02:47:38 2007
+++ llvm/tools/llvm-upgrade/UpgradeParser.y Thu Feb 8 03:07:25 2007
@@ -475,6 +475,14 @@
return V;
}
+/// @brief This just makes any name given to it unique, up to MAX_UINT times.
+static std::string makeNameUnique(const std::string& Name) {
+ static unsigned UniqueNameCounter = 1;
+ std::string Result(Name);
+ Result += ".upgrd." + llvm::utostr(UniqueNameCounter++);
+ return Result;
+}
+
/// getBBVal - This is used for two purposes:
/// * If isDefinition is true, a new basic block with the specified ID is being
/// defined.
@@ -499,9 +507,18 @@
Name = ID.Name;
if (Value *N = CurFun.CurrentFunction->
getValueSymbolTable().lookup(Name)) {
- if (N->getType() != Type::LabelTy)
- error("Name '" + Name + "' does not refer to a BasicBlock");
- BB = cast<BasicBlock>(N);
+ if (N->getType() != Type::LabelTy) {
+ // Register names didn't use to conflict with basic block names
+ // because of type planes. Now they all have to be unique. So, we just
+ // rename the register and treat this name as if no basic block
+ // had been found.
+ RenameMapKey Key = std::make_pair(N->getName(),N->getType());
+ N->setName(makeNameUnique(N->getName()));
+ CurModule.RenameMap[Key] = N->getName();
+ BB = 0;
+ } else {
+ BB = cast<BasicBlock>(N);
+ }
}
break;
}
@@ -623,14 +640,6 @@
}
}
-/// @brief This just makes any name given to it unique, up to MAX_UINT times.
-static std::string makeNameUnique(const std::string& Name) {
- static unsigned UniqueNameCounter = 1;
- std::string Result(Name);
- Result += ".upgrd." + llvm::utostr(UniqueNameCounter++);
- return Result;
-}
-
/// This is the implementation portion of TypeHasInteger. It traverses the
/// type given, avoiding recursive types, and returns true as soon as it finds
/// an integer type. If no integer type is found, it returns false.
More information about the llvm-commits
mailing list