<div dir="ltr">On Mon, Apr 8, 2013 at 10:42 AM, John McCall <span dir="ltr"><<a href="mailto:rjmccall@apple.com" target="_blank" class="cremed">rjmccall@apple.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class=""><div class="h5"><br>
On Apr 6, 2013, at 12:07 AM, Richard Smith <<a href="mailto:richard-llvm@metafoo.co.uk" class="cremed">richard-llvm@metafoo.co.uk</a>> wrote:<br>
<br>
> Author: rsmith<br>
> Date: Sat Apr 6 02:07:44 2013<br>
> New Revision: 178952<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=178952&view=rev" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project?rev=178952&view=rev</a><br>
> Log:<br>
> Remove nondeterminism introduced in r178950.<br>
><br>
> Modified:<br>
> cfe/trunk/lib/CodeGen/CodeGenModule.cpp<br>
> cfe/trunk/lib/CodeGen/CodeGenModule.h<br>
><br>
> Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=178952&r1=178951&r2=178952&view=diff" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=178952&r1=178951&r2=178952&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)<br>
> +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Sat Apr 6 02:07:44 2013<br>
> @@ -1732,13 +1732,15 @@ void CodeGenModule::MaybeHandleStaticInE<br>
> // OK, this is an internal linkage entity inside an extern "C" linkage<br>
> // specification. Make a note of that so we can give it the "expected"<br>
> // mangled name if nothing else is using that name.<br>
> - StaticExternCMap::iterator I =<br>
> - StaticExternCValues.insert(std::make_pair(D->getIdentifier(), GV)).first;<br>
> + std::pair<StaticExternCMap::iterator, bool> R =<br>
> + StaticExternCValues.insert(std::make_pair(D->getIdentifier(), GV));<br>
><br>
> // If we have multiple internal linkage entities with the same name<br>
> // in extern "C" regions, none of them gets that name.<br>
> - if (I->second != GV)<br>
> - I->second = 0;<br>
> + if (!R.second)<br>
> + R.first->second = 0;<br>
> + else<br>
> + StaticExternCIdents.push_back(D->getIdentifier());<br>
> }<br>
><br>
> void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) {<br>
> @@ -2947,13 +2949,13 @@ static void EmitGlobalDeclMetadata(CodeG<br>
> /// to such functions with an unmangled name from inline assembly within the<br>
> /// same translation unit.<br>
> void CodeGenModule::EmitStaticExternCAliases() {<br>
> - for (StaticExternCMap::iterator I = StaticExternCValues.begin(),<br>
> - E = StaticExternCValues.end();<br>
> - I != E; ++I)<br>
> - if (I->second && !getModule().getNamedValue(I->first->getName()))<br>
> - AddUsedGlobal(<br>
> - new llvm::GlobalAlias(I->second->getType(), I->second->getLinkage(),<br>
> - I->first->getName(), I->second, &getModule()));<br>
> + for (unsigned I = 0, N = StaticExternCIdents.size(); I != N; ++I) {<br>
> + IdentifierInfo *Name = StaticExternCIdents[I];<br>
> + llvm::GlobalValue *Val = StaticExternCValues[Name];<br>
> + if (Val && !getModule().getNamedValue(Name->getName()))<br>
> + AddUsedGlobal(new llvm::GlobalAlias(Val->getType(), Val->getLinkage(),<br>
> + Name->getName(), Val, &getModule()));<br>
> + }<br>
> }<br>
><br>
> /// Emits metadata nodes associating all the global values in the<br>
><br>
> Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=178952&r1=178951&r2=178952&view=diff" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=178952&r1=178951&r2=178952&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)<br>
> +++ cfe/trunk/lib/CodeGen/CodeGenModule.h Sat Apr 6 02:07:44 2013<br>
> @@ -310,6 +310,7 @@ class CodeGenModule : public CodeGenType<br>
> typedef llvm::DenseMap<IdentifierInfo *,<br>
> llvm::GlobalValue *> StaticExternCMap;<br>
> StaticExternCMap StaticExternCValues;<br>
> + std::vector<IdentifierInfo*> StaticExternCIdents;<br>
<br>
</div></div>I think this is just llvm::MapVector<IdentifierInfo*, llvm::GlobalValue*>.<br></blockquote><div><br></div><div style>Huh, I somehow didn't find that despite looking for it. r179438, thanks!</div></div>
</div></div>