r203151 - MS ABI: Disambiguate the manglings for global guard variables
David Majnemer
david.majnemer at gmail.com
Thu Mar 6 11:57:36 PST 2014
Author: majnemer
Date: Thu Mar 6 13:57:36 2014
New Revision: 203151
URL: http://llvm.org/viewvc/llvm-project?rev=203151&view=rev
Log:
MS ABI: Disambiguate the manglings for global guard variables
If a guard variable will be created for an entity at global scope,
then we cannot rely on the scope depth to disambiguate names for us.
Instead, mangle the entire variable into the guard to ensure it's uniqueness.
Modified:
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/test/CodeGenCXX/microsoft-abi-static-initializers.cpp
Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=203151&r1=203150&r2=203151&view=diff
==============================================================================
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Thu Mar 6 13:57:36 2014
@@ -2280,13 +2280,17 @@ void MicrosoftMangleContextImpl::mangleS
bool Visible = VD->isExternallyVisible();
// <operator-name> ::= ?_B # local static guard
Mangler.getStream() << (Visible ? "\01??_B" : "\01?$S1@");
- Mangler.mangleNestedName(VD);
+ unsigned ScopeDepth = 0;
+ if (Visible && !getNextDiscriminator(VD, ScopeDepth))
+ // If we do not have a discriminator and are emitting a guard variable for
+ // use at global scope, then mangling the nested name will not be enough to
+ // remove ambiguities.
+ Mangler.mangle(VD, "");
+ else
+ Mangler.mangleNestedName(VD);
Mangler.getStream() << (Visible ? "@5" : "@4IA");
- if (Visible) {
- unsigned ScopeDepth;
- getNextDiscriminator(VD, ScopeDepth);
+ if (ScopeDepth)
Mangler.mangleNumber(ScopeDepth);
- }
}
void MicrosoftMangleContextImpl::mangleInitFiniStub(const VarDecl *D,
Modified: cfe/trunk/test/CodeGenCXX/microsoft-abi-static-initializers.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-static-initializers.cpp?rev=203151&r1=203150&r2=203151&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-static-initializers.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-static-initializers.cpp Thu Mar 6 13:57:36 2014
@@ -135,6 +135,8 @@ void force_usage() {
}
// CHECK: define internal void @"\01??__Efoo@?$B at H@@2VA@@A at YAXXZ"() [[NUW]]
+// CHECK: load i32* @"\01??_Bfoo@?$B at H@@2VA@@A at 5"
+// CHECK: store i32 {{.*}}, i32* @"\01??_Bfoo@?$B at H@@2VA@@A at 5"
// CHECK: %{{[.0-9A-Z_a-z]+}} = call x86_thiscallcc %class.A* @"\01??0A@@QAE at XZ"
// CHECK: call i32 @atexit(void ()* @"\01??__Ffoo@?$B at H@@2VA@@A at YAXXZ")
// CHECK: ret void
More information about the cfe-commits
mailing list