DAE bug fix. Don't lose parameter attributes on vararg arguments.
authorEvan Cheng <evan.cheng@apple.com>
Thu, 17 Jan 2008 04:18:54 +0000 (04:18 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Thu, 17 Jan 2008 04:18:54 +0000 (04:18 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46113 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/IPO/DeadArgumentElimination.cpp

index b8770121eb0fba424a2265022235df316937d841..3a4c36f87f1a0ff88e80e57d5438f4c2da17eaa3 100644 (file)
@@ -590,15 +590,19 @@ void DAE::RemoveDeadArgumentsFromFunction(Function *F) {
           ParamAttrsVec.push_back(ParamAttrsWithIndex::get(Args.size(), Attrs));
       }
 
-    // Reconstruct the ParamAttrsList based on the vector we constructed.
-    PAL = ParamAttrsList::get(ParamAttrsVec);
-
     if (ExtraArgHack)
       Args.push_back(UndefValue::get(Type::Int32Ty));
 
-    // Push any varargs arguments on the list
-    for (; AI != CS.arg_end(); ++AI)
+    // Push any varargs arguments on the list. Don't forget their attributes.
+    for (; AI != CS.arg_end(); ++AI) {
       Args.push_back(*AI);
+      uint16_t Attrs = PAL ? PAL->getParamAttrs(index++) : 0;
+      if (Attrs)
+        ParamAttrsVec.push_back(ParamAttrsWithIndex::get(Args.size(), Attrs));
+    }
+
+    // Reconstruct the ParamAttrsList based on the vector we constructed.
+    PAL = ParamAttrsList::get(ParamAttrsVec);
 
     Instruction *New;
     if (InvokeInst *II = dyn_cast<InvokeInst>(Call)) {