summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2007-02-08 09:07:25 +0000
committerReid Spencer <rspencer@reidspencer.com>2007-02-08 09:07:25 +0000
commitac6d60899dd82ee04919b1ffa510b7a9c44f8ae0 (patch)
tree194e6303a43fc35d9cabfb9fdf14d8b553b0c251 /tools
parent39a9792d54f26189967fa12036cf5860d8c62884 (diff)
downloadllvm-ac6d60899dd82ee04919b1ffa510b7a9c44f8ae0.tar.gz
llvm-ac6d60899dd82ee04919b1ffa510b7a9c44f8ae0.tar.bz2
llvm-ac6d60899dd82ee04919b1ffa510b7a9c44f8ae0.tar.xz
For PR1187:
Rename function scope names that conflict with basic block names. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34048 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/llvm-upgrade/UpgradeParser.y31
1 files changed, 20 insertions, 11 deletions
diff --git a/tools/llvm-upgrade/UpgradeParser.y b/tools/llvm-upgrade/UpgradeParser.y
index 8a213707ab..ad72b3996a 100644
--- a/tools/llvm-upgrade/UpgradeParser.y
+++ b/tools/llvm-upgrade/UpgradeParser.y
@@ -475,6 +475,14 @@ static Value *getVal(const Type *Ty, const ValID &ID) {
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 @@ static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
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 @@ static void ResolveTypeTo(char *Name, const Type *ToTy) {
}
}
-/// @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.