[cfe-commits] r97055 - /cfe/trunk/lib/CodeGen/CGCXX.cpp
John McCall
rjmccall at apple.com
Wed Feb 24 12:32:01 PST 2010
Author: rjmccall
Date: Wed Feb 24 14:32:01 2010
New Revision: 97055
URL: http://llvm.org/viewvc/llvm-project?rev=97055&view=rev
Log:
Fix an iterator-invalidation bug that was causing selfhost errors
on non-darwin platforms. Fixes PR6411. Test case doesn't reduce,
unfortunately.
Modified:
cfe/trunk/lib/CodeGen/CGCXX.cpp
Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=97055&r1=97054&r2=97055&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Wed Feb 24 14:32:01 2010
@@ -140,15 +140,6 @@
const llvm::PointerType *AliasType
= getTypes().GetFunctionType(AliasDecl)->getPointerTo();
- // Look for an existing entry.
- const char *MangledName = getMangledName(AliasDecl);
- llvm::GlobalValue *&Entry = GlobalDeclMap[MangledName];
- if (Entry) {
- assert(Entry->isDeclaration() && "definition already exists for alias");
- assert(Entry->getType() == AliasType &&
- "declaration exists with different type");
- }
-
// Find the referrent. Some aliases might require a bitcast, in
// which case the caller is responsible for ensuring the soundness
// of these semantics.
@@ -161,8 +152,13 @@
llvm::GlobalAlias *Alias =
new llvm::GlobalAlias(AliasType, Linkage, "", Aliasee, &getModule());
- // Switch any previous uses to the alias and kill the previous decl.
+ // Switch any previous uses to the alias.
+ const char *MangledName = getMangledName(AliasDecl);
+ llvm::GlobalValue *&Entry = GlobalDeclMap[MangledName];
if (Entry) {
+ assert(Entry->isDeclaration() && "definition already exists for alias");
+ assert(Entry->getType() == AliasType &&
+ "declaration exists with different type");
Entry->replaceAllUsesWith(Alias);
Entry->eraseFromParent();
}
More information about the cfe-commits
mailing list