Fixing several transforms which would drop the collector attribute
authorGordon Henriksen <gordonhenriksen@mac.com>
Tue, 25 Dec 2007 22:16:06 +0000 (22:16 +0000)
committerGordon Henriksen <gordonhenriksen@mac.com>
Tue, 25 Dec 2007 22:16:06 +0000 (22:16 +0000)
when copying functions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45356 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Linker/LinkModules.cpp
lib/Transforms/IPO/ArgumentPromotion.cpp
lib/Transforms/IPO/DeadArgumentElimination.cpp
lib/Transforms/IPO/ExtractFunction.cpp
tools/llvm2cpp/CppWriter.cpp

index 0f2afe54c97ec1a36a0b8bff06aaea16ee57e41a..3aea74e79d28a0924336d968a27b55a5cb10a682 100644 (file)
@@ -359,6 +359,8 @@ static void CopyGVAttributes(GlobalValue *DestGV, const GlobalValue *SrcGV) {
     Function *DestF = cast<Function>(DestGV);
     DestF->setCallingConv(SrcF->getCallingConv());
     DestF->setParamAttrs(SrcF->getParamAttrs());
+    if (SrcF->hasCollector())
+      DestF->setCollector(SrcF->getCollector());
   }
 }
 
index 26d8853891eaac7c93142d3d839a5c5fd04c0dd0..c66b28524eb4c6cc037e4247c5530d72e4c73446 100644 (file)
@@ -424,6 +424,8 @@ Function *ArgPromotion::DoPromotion(Function *F,
   Function *NF = new Function(NFTy, F->getLinkage(), F->getName());
   NF->setCallingConv(F->getCallingConv());
   NF->setParamAttrs(PAL);
+  if (F->hasCollector())
+    NF->setCollector(F->getCollector());
   F->getParent()->getFunctionList().insert(F, NF);
 
   // Get the alias analysis information that we need to update to reflect our
index 6674ffdf7b89cec7517a1276c4e86227893c9ec5..d611307c2f909c03d0c20222a1b66cb0a42371d1 100644 (file)
@@ -159,6 +159,8 @@ bool DAE::DeleteDeadVarargs(Function &Fn) {
   Function *NF = new Function(NFTy, Fn.getLinkage());
   NF->setCallingConv(Fn.getCallingConv());
   NF->setParamAttrs(Fn.getParamAttrs());
+  if (Fn.hasCollector())
+    NF->setCollector(Fn.getCollector());
   Fn.getParent()->getFunctionList().insert(&Fn, NF);
   NF->takeName(&Fn);
 
@@ -541,6 +543,8 @@ void DAE::RemoveDeadArgumentsFromFunction(Function *F) {
   Function *NF = new Function(NFTy, F->getLinkage());
   NF->setCallingConv(F->getCallingConv());
   NF->setParamAttrs(PAL);
+  if (F->hasCollector())
+    NF->setCollector(F->getCollector());
   F->getParent()->getFunctionList().insert(F, NF);
   NF->takeName(F);
 
index e5b2d41d52893a96dbcbe560c06bdceadf89a63d..013fefef98fc2416895bb1166b37d83c0cc3ba83 100644 (file)
@@ -96,6 +96,8 @@ namespace {
                                        GlobalValue::ExternalLinkage);
           New->setCallingConv(I->getCallingConv());
           New->setParamAttrs(I->getParamAttrs());
+          if (I->hasCollector())
+            New->setCollector(I->getCollector());
 
           // If it's not the named function, delete the body of the function
           I->dropAllReferences();
index b3aaf25a382d4ba3aa6f67987fe295cb3400e422..ccb2a3738bd4230f59c8f58f10341a1adf655c09 100644 (file)
@@ -1572,6 +1572,11 @@ void CppWriter::printFunctionHead(const Function* F) {
     Out << ");";
     nl(Out);
   }
+  if (F->hasCollector()) {
+    printCppName(F);
+    Out << "->setCollector(\"" << F->getCollector() << "\");";
+    nl(Out);
+  }
   if (is_inline) {
     Out << "}";
     nl(Out);