[llvm-commits] [poolalloc] r168326 - in /poolalloc/trunk: lib/DSA/StdLibPass.cpp test/dsa/regression/2012-11-19.ExternFuncSummaries.ll

Will Dietz wdietz2 at illinois.edu
Mon Nov 19 13:08:35 PST 2012


Author: wdietz2
Date: Mon Nov 19 15:08:35 2012
New Revision: 168326

URL: http://llvm.org/viewvc/llvm-project?rev=168326&view=rev
Log:
Fix off-by-one in interpretation of summaries! Patch by Jingyue, thanks!

Add corresponding regression testcase (authored by myself).

Resolves PR12786.

Added:
    poolalloc/trunk/test/dsa/regression/2012-11-19.ExternFuncSummaries.ll
Modified:
    poolalloc/trunk/lib/DSA/StdLibPass.cpp

Modified: poolalloc/trunk/lib/DSA/StdLibPass.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/StdLibPass.cpp?rev=168326&r1=168325&r2=168326&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/StdLibPass.cpp (original)
+++ poolalloc/trunk/lib/DSA/StdLibPass.cpp Mon Nov 19 15:08:35 2012
@@ -418,6 +418,8 @@
   {"_ZNSolsEPFRSoS_E", {NRET_YARGS, NRET_YNARGS, NRET_NARGS, NRET_NARGS, false}},
   //endl
   {"_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_", {NRET_NARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, false}},
+  // Added by Jingyue
+  {"strtoll",       {NRET_YARGS, NRET_NYARGS, NRET_NYARGS, NRET_YARGS, false}},
   // Terminate the list of special functions recognized by this pass
   {0,            {NRET_NARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, false}},
 };
@@ -703,11 +705,11 @@
         for (unsigned y = 0; y < CI->getNumArgOperands(); ++y)
           if (isa<PointerType>(CI->getArgOperand(y)->getType())){
             if (Graph->hasNodeForValue(CI->getArgOperand(y))){
-              if (recFuncs[x].action.read[y])
+              if (recFuncs[x].action.read[y + 1])
                 Graph->getNodeForValue(CI->getArgOperand(y)).getNode()->setReadMarker();
-              if (recFuncs[x].action.write[y])
+              if (recFuncs[x].action.write[y + 1])
                 Graph->getNodeForValue(CI->getArgOperand(y)).getNode()->setModifiedMarker();
-              if (recFuncs[x].action.heap[y])
+              if (recFuncs[x].action.heap[y + 1])
                 Graph->getNodeForValue(CI->getArgOperand(y)).getNode()->setHeapMarker();
             }
           }
@@ -722,7 +724,7 @@
             if (Graph->hasNodeForValue(CI))
               toMerge.push_back(Graph->getNodeForValue(CI));
         for (unsigned y = 0; y < CI->getNumArgOperands(); ++y)
-          if (recFuncs[x].action.mergeNodes[y])
+          if (recFuncs[x].action.mergeNodes[y + 1])
             if (isa<PointerType>(CI->getArgOperand(y)->getType()))
               if (Graph->hasNodeForValue(CI->getArgOperand(y)))
                 toMerge.push_back(Graph->getNodeForValue(CI->getArgOperand(y)));
@@ -775,11 +777,11 @@
         for (unsigned y = 0; y < CI->getNumArgOperands(); ++y)
           if (isa<PointerType>(CI->getArgOperand(y)->getType())){
             if (Graph->hasNodeForValue(CI->getArgOperand(y))){
-              if (recFuncs[x].action.read[y])
+              if (recFuncs[x].action.read[y + 1])
                 Graph->getNodeForValue(CI->getArgOperand(y)).getNode()->setReadMarker();
-              if (recFuncs[x].action.write[y])
+              if (recFuncs[x].action.write[y + 1])
                 Graph->getNodeForValue(CI->getArgOperand(y)).getNode()->setModifiedMarker();
-              if (recFuncs[x].action.heap[y])
+              if (recFuncs[x].action.heap[y + 1])
                 Graph->getNodeForValue(CI->getArgOperand(y)).getNode()->setHeapMarker();
             }
           }
@@ -794,7 +796,7 @@
             if (Graph->hasNodeForValue(CI))
               toMerge.push_back(Graph->getNodeForValue(CI));
         for (unsigned y = 0; y < CI->getNumArgOperands(); ++y)
-          if (recFuncs[x].action.mergeNodes[y])
+          if (recFuncs[x].action.mergeNodes[y + 1])
             if (isa<PointerType>(CI->getArgOperand(y)->getType()))
               if (Graph->hasNodeForValue(CI->getArgOperand(y)))
                 toMerge.push_back(Graph->getNodeForValue(CI->getArgOperand(y)));
@@ -850,7 +852,7 @@
               // as appropriate.
               //
               for (unsigned y = 0; y < CI->getNumArgOperands(); ++y)
-                if (recFuncs[x].action.read[y]){
+                if (recFuncs[x].action.read[y + 1]){
                   if (isa<PointerType>(CI->getArgOperand(y)->getType())){
                     if (Graph->hasNodeForValue(CI->getArgOperand(y)))
                       Graph->getNodeForValue(CI->getArgOperand(y)).getNode()->setReadMarker();
@@ -871,7 +873,7 @@
                   if (Graph->hasNodeForValue(CI))
                     toMerge.push_back(Graph->getNodeForValue(CI));
               for (unsigned y = 0; y < CI->getNumArgOperands(); ++y)
-                if (recFuncs[x].action.mergeNodes[y])
+                if (recFuncs[x].action.mergeNodes[y + 1])
                   if (isa<PointerType>(CI->getArgOperand(y)->getType()))
                     if (Graph->hasNodeForValue(CI->getArgOperand(y)))
                       toMerge.push_back(Graph->getNodeForValue(CI->getArgOperand(y)));

Added: poolalloc/trunk/test/dsa/regression/2012-11-19.ExternFuncSummaries.ll
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/regression/2012-11-19.ExternFuncSummaries.ll?rev=168326&view=auto
==============================================================================
--- poolalloc/trunk/test/dsa/regression/2012-11-19.ExternFuncSummaries.ll (added)
+++ poolalloc/trunk/test/dsa/regression/2012-11-19.ExternFuncSummaries.ll Mon Nov 19 15:08:35 2012
@@ -0,0 +1,23 @@
+; PR12786
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
+target triple = "x86_64-unknown-linux-gnu"
+
+declare i8* @getcwd(i8*) nounwind
+
+; Result of getcwd should be merged with its argument
+; RUN: dsaopt %s -dsa-stdlib -analyze -check-same-node=test_cwd:ret,test_cwd:arg
+define i8* @test_cwd(i8* %arg) nounwind {
+  %ret = call i8* @getcwd(i8* %arg) nounwind
+  ret i8* %ret
+}
+
+declare i8* @strstr(i8*,i8*) nounwind
+
+; Result of strstr should be merged with its first argument, second should be separate
+; RUN: dsaopt %s -dsa-stdlib -analyze -check-same-node=test_strstr:ret,test_strstr:arg1
+; RUN: dsaopt %s -dsa-stdlib -analyze -check-not-same-node=test_strstr:ret,test_strstr:arg2
+; RUN: dsaopt %s -dsa-stdlib -analyze -check-not-same-node=test_strstr:arg1,test_strstr:arg2
+define i8* @test_strstr(i8* %arg1, i8* %arg2) nounwind {
+  %ret = call i8* @strstr(i8* %arg1, i8* %arg2) nounwind
+  ret i8* %ret
+}





More information about the llvm-commits mailing list