[cfe-commits] r172692 - in /cfe/trunk: lib/CodeGen/CodeGenModule.cpp test/Modules/autolink.m

Daniel Dunbar daniel at zuster.org
Wed Jan 16 17:35:06 PST 2013


Author: ddunbar
Date: Wed Jan 16 19:35:06 2013
New Revision: 172692

URL: http://llvm.org/viewvc/llvm-project?rev=172692&view=rev
Log:
[IRgen] Update modules autolink metadata to use module flags (as now specified
in the LangRef).

Modified:
    cfe/trunk/lib/CodeGen/CodeGenModule.cpp
    cfe/trunk/test/Modules/autolink.m

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=172692&r1=172691&r2=172692&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Wed Jan 16 19:35:06 2013
@@ -723,7 +723,7 @@
 /// it depends on, using a postorder walk.
 static void addLinkOptionsPostorder(llvm::LLVMContext &Context,
                                     Module *Mod,
-                                    SmallVectorImpl<llvm::MDNode *> &Metadata,
+                                    SmallVectorImpl<llvm::Value *> &Metadata,
                                     llvm::SmallPtrSet<Module *, 16> &Visited) {
   // Import this module's parent.
   if (Mod->Parent && Visited.insert(Mod->Parent)) {
@@ -810,7 +810,7 @@
 
   // Add link options for all of the imported modules in reverse topological
   // order.
-  SmallVector<llvm::MDNode *, 16> MetadataArgs;
+  SmallVector<llvm::Value *, 16> MetadataArgs;
   Visited.clear();
   for (llvm::SetVector<clang::Module *>::iterator M = LinkModules.begin(),
                                                MEnd = LinkModules.end();
@@ -818,15 +818,11 @@
     if (Visited.insert(*M))
       addLinkOptionsPostorder(getLLVMContext(), *M, MetadataArgs, Visited);
   }
+  std::reverse(MetadataArgs.begin(), MetadataArgs.end());
 
-  // Get/create metadata for the link options.
-  llvm::NamedMDNode *Metadata
-    = getModule().getOrInsertNamedMetadata("llvm.module.linkoptions");
-
-  // Add link options in topological order.
-  for (unsigned I = MetadataArgs.size(); I > 0; --I) {
-    Metadata->addOperand(MetadataArgs[I-1]);
-  }
+  // Add the linker options metadata flag.
+  getModule().addModuleFlag(llvm::Module::AppendUnique, "Linker Options",
+                            llvm::MDNode::get(getLLVMContext(), MetadataArgs));
 }
 
 void CodeGenModule::EmitDeferred() {

Modified: cfe/trunk/test/Modules/autolink.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/autolink.m?rev=172692&r1=172691&r2=172692&view=diff
==============================================================================
--- cfe/trunk/test/Modules/autolink.m (original)
+++ cfe/trunk/test/Modules/autolink.m Wed Jan 16 19:35:06 2013
@@ -28,7 +28,9 @@
   return no_umbrella_A;
 }
 
-// CHECK: !llvm.module.linkoptions = !{![[AUTOLINK_FRAMEWORK:[0-9]+]], ![[AUTOLINK:[0-9]+]], ![[DEPENDSONMODULE:[0-9]+]], ![[MODULE:[0-9]+]], ![[NOUMBRELLA:[0-9]+]]}
+// CHECK: !llvm.module.flags = !{!0, !1, !2, !3, !4}
+// CHECK: !4 = metadata !{i32 6, metadata !"Linker Options", metadata ![[AUTOLINK_OPTIONS:[0-9]+]]}
+// CHECK: ![[AUTOLINK_OPTIONS]] = metadata !{metadata ![[AUTOLINK_FRAMEWORK:[0-9]+]], metadata ![[AUTOLINK:[0-9]+]], metadata ![[DEPENDSONMODULE:[0-9]+]], metadata ![[MODULE:[0-9]+]], metadata ![[NOUMBRELLA:[0-9]+]]}
 // CHECK: ![[AUTOLINK_FRAMEWORK]] = metadata !{metadata !"-framework", metadata !"autolink_framework"}
 // CHECK: ![[AUTOLINK]] = metadata !{metadata !"-lautolink"}
 // CHECK: ![[DEPENDSONMODULE]] = metadata !{metadata !"-framework", metadata !"DependsOnModule"}





More information about the cfe-commits mailing list