summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2013-04-06 07:07:44 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2013-04-06 07:07:44 +0000
commit85465e608da9720a9700308d1b1c269d8337cf52 (patch)
tree0f6a8394a585c96da8e27521eb49646f85fedfef /clang/lib/CodeGen/CodeGenModule.cpp
parentb861fe5df292916b4d1794422617ebbb09a5d25d (diff)
downloadbcm5719-llvm-85465e608da9720a9700308d1b1c269d8337cf52.tar.gz
bcm5719-llvm-85465e608da9720a9700308d1b1c269d8337cf52.zip
Remove nondeterminism introduced in r178950.
llvm-svn: 178952
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 670f06620d2..e8e3d1ae76e 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1732,13 +1732,15 @@ void CodeGenModule::MaybeHandleStaticInExternC(const SomeDecl *D,
// OK, this is an internal linkage entity inside an extern "C" linkage
// specification. Make a note of that so we can give it the "expected"
// mangled name if nothing else is using that name.
- StaticExternCMap::iterator I =
- StaticExternCValues.insert(std::make_pair(D->getIdentifier(), GV)).first;
+ std::pair<StaticExternCMap::iterator, bool> R =
+ StaticExternCValues.insert(std::make_pair(D->getIdentifier(), GV));
// If we have multiple internal linkage entities with the same name
// in extern "C" regions, none of them gets that name.
- if (I->second != GV)
- I->second = 0;
+ if (!R.second)
+ R.first->second = 0;
+ else
+ StaticExternCIdents.push_back(D->getIdentifier());
}
void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) {
@@ -2947,13 +2949,13 @@ static void EmitGlobalDeclMetadata(CodeGenModule &CGM,
/// to such functions with an unmangled name from inline assembly within the
/// same translation unit.
void CodeGenModule::EmitStaticExternCAliases() {
- for (StaticExternCMap::iterator I = StaticExternCValues.begin(),
- E = StaticExternCValues.end();
- I != E; ++I)
- if (I->second && !getModule().getNamedValue(I->first->getName()))
- AddUsedGlobal(
- new llvm::GlobalAlias(I->second->getType(), I->second->getLinkage(),
- I->first->getName(), I->second, &getModule()));
+ for (unsigned I = 0, N = StaticExternCIdents.size(); I != N; ++I) {
+ IdentifierInfo *Name = StaticExternCIdents[I];
+ llvm::GlobalValue *Val = StaticExternCValues[Name];
+ if (Val && !getModule().getNamedValue(Name->getName()))
+ AddUsedGlobal(new llvm::GlobalAlias(Val->getType(), Val->getLinkage(),
+ Name->getName(), Val, &getModule()));
+ }
}
/// Emits metadata nodes associating all the global values in the
OpenPOWER on IntegriCloud