aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/AsmParser/LLParser.cpp13
-rw-r--r--test/CodeGen/CPP/llvm2cpp.ll2
-rw-r--r--test/CodeGen/X86/x86-64-pic-10.ll2
3 files changed, 10 insertions, 7 deletions
diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp
index 52fd2b2..fa803bb 100644
--- a/lib/AsmParser/LLParser.cpp
+++ b/lib/AsmParser/LLParser.cpp
@@ -603,8 +603,7 @@ bool LLParser::ParseAlias(const std::string &Name, LocTy NameLoc,
// See if this value already exists in the symbol table. If so, it is either
// a redefinition or a definition of a forward reference.
- if (GlobalValue *Val =
- cast_or_null<GlobalValue>(M->getValueSymbolTable().lookup(Name))) {
+ if (GlobalValue *Val = M->getNamedValue(Name)) {
// See if this was a redefinition. If so, there is no entry in
// ForwardRefVals.
std::map<std::string, std::pair<GlobalValue*, LocTy> >::iterator
@@ -671,9 +670,11 @@ bool LLParser::ParseGlobal(const std::string &Name, LocTy NameLoc,
// See if the global was forward referenced, if so, use the global.
if (!Name.empty()) {
- if ((GV = M->getGlobalVariable(Name, true)) &&
- !ForwardRefVals.erase(Name))
- return Error(NameLoc, "redefinition of global '@" + Name + "'");
+ if (GlobalValue *GVal = M->getNamedValue(Name)) {
+ if (!ForwardRefVals.erase(Name) || !isa<GlobalValue>(GVal))
+ return Error(NameLoc, "redefinition of global '@" + Name + "'");
+ GV = cast<GlobalVariable>(GVal);
+ }
} else {
std::map<unsigned, std::pair<GlobalValue*, LocTy> >::iterator
I = ForwardRefValIDs.find(NumberedVals.size());
@@ -2563,6 +2564,8 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) {
AI != AE; ++AI)
AI->setName("");
}
+ } else if (M->getNamedValue(FunctionName)) {
+ return Error(NameLoc, "redefinition of function '@" + FunctionName + "'");
}
} else {
diff --git a/test/CodeGen/CPP/llvm2cpp.ll b/test/CodeGen/CPP/llvm2cpp.ll
index 447f332..d0ba0cf 100644
--- a/test/CodeGen/CPP/llvm2cpp.ll
+++ b/test/CodeGen/CPP/llvm2cpp.ll
@@ -273,7 +273,7 @@ define i32 @foozball(i32) {
@A = global i32* @B ; <i32**> [#uses=0]
@B = global i32 7 ; <i32*> [#uses=1]
-define void @X() {
+define void @test12312() {
ret void
}
; ModuleID = 'global_section.ll'
diff --git a/test/CodeGen/X86/x86-64-pic-10.ll b/test/CodeGen/X86/x86-64-pic-10.ll
index 0f65e57..7baa7e5 100644
--- a/test/CodeGen/X86/x86-64-pic-10.ll
+++ b/test/CodeGen/X86/x86-64-pic-10.ll
@@ -3,7 +3,7 @@
@g = alias weak i32 ()* @f
-define void @g() {
+define void @h() {
entry:
%tmp31 = call i32 @g()
ret void