[llvm-commits] [dragonegg] r90844 - /dragonegg/trunk/llvm-backend.cpp

Duncan Sands baldrick at free.fr
Tue Dec 8 00:22:43 PST 2009


Author: baldrick
Date: Tue Dec  8 02:22:43 2009
New Revision: 90844

URL: http://llvm.org/viewvc/llvm-project?rev=90844&view=rev
Log:
Reintroduce emit_same_body_alias, since this seems more logical
and I am still fighting with getting their linkage right.  Tidy
the linkage logic in emit_alias_to_llvm.

Modified:
    dragonegg/trunk/llvm-backend.cpp

Modified: dragonegg/trunk/llvm-backend.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-backend.cpp?rev=90844&r1=90843&r2=90844&view=diff

==============================================================================
--- dragonegg/trunk/llvm-backend.cpp (original)
+++ dragonegg/trunk/llvm-backend.cpp Tue Dec  8 02:22:43 2009
@@ -1686,16 +1686,11 @@
 
   GlobalValue::LinkageTypes Linkage;
 
-  // A weak alias has TREE_PUBLIC set but not the other bits.
-  if (false)//FIXME DECL_LLVM_PRIVATE(decl))
-    Linkage = GlobalValue::PrivateLinkage;
-  else if (false)//FIXME DECL_LLVM_LINKER_PRIVATE(decl))
-    Linkage = GlobalValue::LinkerPrivateLinkage;
+  if (!TREE_PUBLIC(decl))
+    Linkage = GlobalValue::InternalLinkage;
   else if (DECL_WEAK(decl))
     // The user may have explicitly asked for weak linkage - ignore flag_odr.
     Linkage = GlobalValue::WeakAnyLinkage;
-  else if (!TREE_PUBLIC(decl))
-    Linkage = GlobalValue::InternalLinkage;
   else
     Linkage = GlobalValue::ExternalLinkage;
 
@@ -1726,6 +1721,13 @@
   TREE_ASM_WRITTEN(decl) = 1;
 }
 
+/// emit_same_body_alias - Turn a same-body alias into LLVM IR.
+static void emit_same_body_alias(struct cgraph_node *alias,
+                                 struct cgraph_node *target) {
+  assert(alias->thunk.alias == target->decl && "Unexpected alias target!");
+  emit_alias_to_llvm(alias->decl, target->decl);
+}
+
 /// emit_functions - Turn all functions in the compilation unit into LLVM IR.
 static void emit_functions(cgraph_node_set set) {
   LazilyInitializeModule();
@@ -1744,12 +1746,10 @@
     for (alias = node->same_body; alias && alias->next; alias = alias->next);
     for (; alias; alias = next) {
       next = alias->previous;
-      if (alias->thunk.thunk_p) {
+      if (alias->thunk.thunk_p)
         emit_thunk_to_llvm(alias);
-      } else {
-        assert(alias->thunk.alias == node->decl && "Unexpected alias target!");
-        emit_alias_to_llvm(alias->decl, node->decl);
-      }
+      else
+        emit_same_body_alias(alias, node);
     }
   }
 }





More information about the llvm-commits mailing list