obj2yaml: Use the correct relocation type for different machine types
[oota-llvm.git] / lib / IR / Mangler.cpp
index 5a099738d55a12f7ab104dc4ce830688b78aebc6..d82388fdbf41229995ba1fd3a6154008b3181191 100644 (file)
@@ -44,13 +44,14 @@ static void getNameWithPrefixx(raw_ostream &OS, const Twine &GVName,
   OS << Name;
 }
 
-void Mangler::getNameWithPrefix(raw_ostream &OS,
-                                const Twine &GVName, ManglerPrefixTy PrefixTy) {
+void Mangler::getNameWithPrefix(raw_ostream &OS, const Twine &GVName,
+                                ManglerPrefixTy PrefixTy) const {
   return getNameWithPrefixx(OS, GVName, PrefixTy, *DL, false);
 }
 
 void Mangler::getNameWithPrefix(SmallVectorImpl<char> &OutName,
-                                const Twine &GVName, ManglerPrefixTy PrefixTy) {
+                                const Twine &GVName,
+                                ManglerPrefixTy PrefixTy) const {
   raw_svector_ostream OS(OutName);
   return getNameWithPrefix(OS, GVName, PrefixTy);
 }
@@ -65,8 +66,8 @@ static void AddFastCallStdCallSuffix(raw_ostream &OS, const Function *F,
   for (Function::const_arg_iterator AI = F->arg_begin(), AE = F->arg_end();
        AI != AE; ++AI) {
     Type *Ty = AI->getType();
-    // 'Dereference' type in case of byval parameter attribute
-    if (AI->hasByValAttr())
+    // 'Dereference' type in case of byval or inalloca parameter attribute.
+    if (AI->hasByValOrInAllocaAttr())
       Ty = cast<PointerType>(Ty)->getElementType();
     // Size should be aligned to DWORD boundary
     ArgWords += ((TD.getTypeAllocSize(Ty) + 3)/4)*4;
@@ -75,12 +76,15 @@ static void AddFastCallStdCallSuffix(raw_ostream &OS, const Function *F,
   OS << '@' << ArgWords;
 }
 
-void Mangler::getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV) {
+void Mangler::getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV,
+                                bool CannotUsePrivateLabel) const {
   ManglerPrefixTy PrefixTy = Mangler::Default;
-  if (GV->hasPrivateLinkage())
-    PrefixTy = Mangler::Private;
-  else if (GV->hasLinkerPrivateLinkage() || GV->hasLinkerPrivateWeakLinkage())
-    PrefixTy = Mangler::LinkerPrivate;
+  if (GV->hasPrivateLinkage()) {
+    if (CannotUsePrivateLabel)
+      PrefixTy = Mangler::LinkerPrivate;
+    else
+      PrefixTy = Mangler::Private;
+  }
 
   if (!GV->hasName()) {
     // Get the ID for the global, assigning a new one if we haven't got one
@@ -133,7 +137,8 @@ void Mangler::getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV) {
 }
 
 void Mangler::getNameWithPrefix(SmallVectorImpl<char> &OutName,
-                                const GlobalValue *GV) {
+                                const GlobalValue *GV,
+                                bool CannotUsePrivateLabel) const {
   raw_svector_ostream OS(OutName);
-  getNameWithPrefix(OS, GV);
+  getNameWithPrefix(OS, GV, CannotUsePrivateLabel);
 }