<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Passing big array to some function makes compilation very slow"
   href="http://llvm.org/bugs/show_bug.cgi?id=22598">22598</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Passing big array to some function makes compilation very slow
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.5
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Common Code Generator Code
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>lin90162@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Hi.

When I was developing my compiler with LLVM,  I noticed the case when
compilation didn't finish.  I reduced the LLVM IR which my compiler emitted as
below



;;;;;;;;;;;;;;
;;  Start  ;;
;;;;;;;;;;;;;;

; ModuleID = 'foo.dcs'
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-darwin13.4.0"

; Function Attrs: nounwind
define i32 @foo([30000 x i64] %x) #0 {
entry:
  ret i32 0
}

; Function Attrs: nounwind
define i32 @main() #0 {
entry:
  %0 = alloca [30000 x i64]
  %1 = bitcast [30000 x i64]* %0 to i8*
  call void @llvm.memset.p0i8.i64(i8* %1, i8 0, i64 240000, i32 8, i1 false)
  %2 = load [30000 x i64]* %0
  %3 = call i32 @foo([30000 x i64] %2)
  ret i32 0
}

; Function Attrs: nounwind
declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i32, i1) #0

attributes #0 = { nounwind }

;;;;;;;;;;;;
;;  end  ;;
;;;;;;;;;;;;



When above code was compiled with llc like below,

$ llc foo.ll

llc took too much time and I ended up with terminating the process.  It seemed
that passing [30000 x i64] made compilation very slow because the issue didn't
occur when I removed calling @foo() and definition of @foo().  And it seemed
not to go into infinite loop because compilation finished when I reduced the
size of array (e.g. 30000 -> 3000).

As I described above, this issue occurred on my compiler at first.  So I tried
debugging with lldb in my desktop.  As the result, it occured in
hasNUsesOfValue() member function of SDNode class which is called by run()
member function of llvm::PassManager.  lldb also said that it entered for loop
in hasNUsesOfValue() very often.

<a href="https://github.com/llvm-mirror/llvm/blob/release_35/lib/CodeGen/SelectionDAG/SelectionDAG.cpp#L6321">https://github.com/llvm-mirror/llvm/blob/release_35/lib/CodeGen/SelectionDAG/SelectionDAG.cpp#L6321</a>




At last my environment is below:

- LLVM (<a href="http://llvm.org/">http://llvm.org/</a>):
    LLVM version 3.5.0
    Optimized build with assertions.
    Built Sep  6 2014 (01:11:29).
    Default target: x86_64-apple-darwin13.4.0
    Host CPU: core-avx2
- iMac 2013 mid

And I confirmed that LLC 3.5.1 in Linux occurred the same problem with above
LLVM IR code.

As reference, my compiler is below:

<a href="https://github.com/rhysd/Dachs">https://github.com/rhysd/Dachs</a></pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>