[poolalloc] r208097 - Improve handling of VAArg nodes, fixes PR19175.

Will Dietz wdietz2 at illinois.edu
Tue May 6 08:56:56 PDT 2014


Author: wdietz2
Date: Tue May  6 10:56:56 2014
New Revision: 208097

URL: http://llvm.org/viewvc/llvm-project?rev=208097&view=rev
Log:
Improve handling of VAArg nodes, fixes PR19175.

Reduced version of test from bug report included.

Thanks Sharan Santhanam for finding and reporting this!

Added:
    poolalloc/trunk/test/dsa/regression/2014-05-06.PR19175-CollapseVA.ll
Modified:
    poolalloc/trunk/lib/DSA/Local.cpp

Modified: poolalloc/trunk/lib/DSA/Local.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Local.cpp?rev=208097&r1=208096&r2=208097&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/Local.cpp (original)
+++ poolalloc/trunk/lib/DSA/Local.cpp Tue May  6 10:56:56 2014
@@ -77,7 +77,7 @@ namespace {
     Function* FB;
     LocalDataStructures* DS;
     const DataLayout& TD;
-    DSNode *VAArray;
+    DSNodeHandle VAArrayNH;
 
     ////////////////////////////////////////////////////////////////////////////
     // Helper functions used to implement the visitation functions...
@@ -146,7 +146,7 @@ namespace {
 
   public:
     GraphBuilder(Function &f, DSGraph &g, LocalDataStructures& DSi)
-      : G(g), FB(&f), DS(&DSi), TD(g.getDataLayout()), VAArray(0) {
+      : G(g), FB(&f), DS(&DSi), TD(g.getDataLayout()), VAArrayNH(0) {
       // Create scalar nodes for all pointer arguments...
       for (Function::arg_iterator I = f.arg_begin(), E = f.arg_end();
            I != E; ++I) {
@@ -208,7 +208,7 @@ namespace {
 
     // GraphBuilder ctor for working on the globals graph
     explicit GraphBuilder(DSGraph& g)
-      :G(g), FB(0), TD(g.getDataLayout()), VAArray(0)
+      :G(g), FB(0), TD(g.getDataLayout()), VAArrayNH(0)
     {}
 
     void mergeInGlobalInitializer(GlobalVariable *GV);
@@ -936,10 +936,10 @@ void GraphBuilder::visitVAStartNode(DSNo
   // Create a dsnode for an array of pointers to the VAInfo for this func
   // We create one such array for each function analyzed, as all
   // calls to va_start will populate their argument with the same data.
-  if (!VAArray) VAArray = createNode();
-  VAArray->setArrayMarker();
-  VAArray->foldNodeCompletely();
-  VAArray->setLink(0,VANH);
+  if (VAArrayNH.isNull()) VAArrayNH.mergeWith(createNode());
+  VAArrayNH.getNode()->setArrayMarker();
+  VAArrayNH.getNode()->foldNodeCompletely();
+  VAArrayNH.setLink(0,VANH);
 
   //VAStart modifies its argument
   N->setModifiedMarker();
@@ -950,9 +950,10 @@ void GraphBuilder::visitVAStartNode(DSNo
   case Triple::x86:
     // On x86, we have:
     // va_list as a pointer to an array of pointers to the variable arguments
-    if (N->getSize() < 1)
+    if (!N->isCollapsedNode() && N->getSize() < 1) {
       N->growSize(1);
-    N->setLink(0, VAArray);
+    }
+    N->addEdgeTo(0, VAArrayNH);
     break;
   case Triple::x86_64:
     // On x86_64, we have va_list as a struct {i32, i32, i8*, i8* }
@@ -960,10 +961,11 @@ void GraphBuilder::visitVAStartNode(DSNo
     // be used also to pass arguments by register.
     // We model this by having both the i8*'s point to an array of pointers
     // to the arguments.
-    if (N->getSize() < 24)
+    if (!N->isCollapsedNode() && N->getSize() < 24) {
       N->growSize(24); //sizeof the va_list struct mentioned above
-    N->setLink(8,VAArray); //first i8*
-    N->setLink(16,VAArray); //second i8*
+    }
+    N->addEdgeTo(8, VAArrayNH); // first i8*
+    N->addEdgeTo(16, VAArrayNH); // second i8*
 
     break;
   default:

Added: poolalloc/trunk/test/dsa/regression/2014-05-06.PR19175-CollapseVA.ll
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/regression/2014-05-06.PR19175-CollapseVA.ll?rev=208097&view=auto
==============================================================================
--- poolalloc/trunk/test/dsa/regression/2014-05-06.PR19175-CollapseVA.ll (added)
+++ poolalloc/trunk/test/dsa/regression/2014-05-06.PR19175-CollapseVA.ll Tue May  6 10:56:56 2014
@@ -0,0 +1,29 @@
+; RUN: dsaopt %s -dsa-local -disable-output
+; (Reduced testcase from submitted file demonstrating assertion failure)
+; PR19175
+; "Assert fails because a node collapse while handling a Vararg within structure on LocalDataStructure Analysis"
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+%struct.__va_list_tag.0.2.16 = type { i32, i32, i8*, i8* }
+%struct.t.1.3.17 = type { [1 x %struct.__va_list_tag.0.2.16], i8* }
+
+; Function Attrs: nounwind
+declare void @llvm.va_start(i8*) #0
+
+; Function Attrs: nounwind uwtable
+define void @test_va_bugging_func(i32 %p1, ...) #1 {
+entry:
+  %v = getelementptr inbounds %struct.t.1.3.17* undef, i32 0, i32 0
+  %arraydecay = getelementptr inbounds [1 x %struct.__va_list_tag.0.2.16]* %v, i32 0, i32 0
+  %arraydecay1 = bitcast %struct.__va_list_tag.0.2.16* %arraydecay to i8*
+  call void @llvm.va_start(i8* %arraydecay1)
+  unreachable
+}
+
+attributes #0 = { nounwind }
+attributes #1 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
+
+!llvm.ident = !{!0}
+
+!0 = metadata !{metadata !"clang version 3.5.0 (git://github.com/llvm-mirror/clang.git 2afa00ce8693eaf81335e4ab629ac1247a461cac) (git://github.com/llvm-mirror/llvm.git 3b4c8c2b2ab2a4af00d03b1b39b1b1eaf564ab76)"}





More information about the llvm-commits mailing list