<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 --- - Segmentation fault with -O2 -g"
   href="http://llvm.org/bugs/show_bug.cgi?id=20612">20612</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Segmentation fault with -O2 -g
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>Linux
          </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>Backend: AArch64
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>liujiangning1@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>Created <span class=""><a href="attachment.cgi?id=12875" name="attach_12875" title="a test case to expose failure">attachment 12875</a> <a href="attachment.cgi?id=12875&action=edit" title="a test case to expose failure">[details]</a></span>
a test case to expose failure

Hi,

For the test case below,

{code}
void f (int *);

int test_dgi (void)
{
  int arg1[4];
  int prod[4 * 2];
  int carry;
  int i, j, k;

  f (arg1);

  for (i = 0; i < 4; i++)
    {
      carry = 0;
      for (j = 0; j < 4; j++)
        {
          k = i + j;                                                            
          carry += arg1[i] * arg1[j];
          carry += prod[k];
          prod[k] = (carry >> 1);
        }
    }

  return 0;
}
{code}

we have compile-time segmentation failure with command line option

clang -O2 -target arm64-linux-gnueabi ff_i.c -g

But the case can build pass, if "-g" is removed.

Attached .ll file is generated by "clang -mtriple=arm64-linux-gnueabi -O2 -g -S
-emit-llvm". With command line option "llc -O2 -mtriple=arm64-linux-gnueabi
ff_i_g.ll", we have the following failure,

llc: /home/jialiu01/llvm/review/llvm/lib/CodeGen/MachineTraceMetrics.cpp:628:
<anonymous namespace>::DataDep::DataDep(const llvm::MachineRegisterInfo *,
unsigned int, unsigned int): Assertion `!DefI.atEnd() && "Register has no
defs"' failed.
0  libLLVMSupport.so 0x00007f95ac04f15e llvm::sys::PrintStackTrace(_IO_FILE*) +
46
1  libLLVMSupport.so 0x00007f95ac04f41b
2  libLLVMSupport.so 0x00007f95ac04f68e
3  libpthread.so.0   0x00007f95aad17bb0
4  libc.so.6         0x00007f95a9f3df77 gsignal + 55
5  libc.so.6         0x00007f95a9f415e8 abort + 328
6  libc.so.6         0x00007f95a9f36d43
7  libc.so.6         0x00007f95a9f36df2
8  libLLVMCodeGen.so 0x00007f95acfcfc12
9  libLLVMCodeGen.so 0x00007f95acfcaf05
10 libLLVMCodeGen.so 0x00007f95acfca78e
llvm::MachineTraceMetrics::Ensemble::computeInstrDepths(llvm::MachineBasicBlock
const*) + 1438
11 libLLVMCodeGen.so 0x00007f95acfcd1da
llvm::MachineTraceMetrics::Ensemble::getTrace(llvm::MachineBasicBlock const*) +
42
12 libLLVMCodeGen.so 0x00007f95acf1c6a3
13 libLLVMCodeGen.so 0x00007f95acf1c3bc
14 libLLVMCodeGen.so 0x00007f95acf43dee
llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 110
15 libLLVMCore.so    0x00007f95acb0f06b
llvm::FPPassManager::runOnFunction(llvm::Function&) + 427
16 libLLVMCore.so    0x00007f95acb0f378
llvm::FPPassManager::runOnModule(llvm::Module&) + 104
17 libLLVMCore.so    0x00007f95acb0fa4a
18 libLLVMCore.so    0x00007f95acb0f62e
llvm::legacy::PassManagerImpl::run(llvm::Module&) + 302
19 libLLVMCore.so    0x00007f95acb0fef1
llvm::legacy::PassManager::run(llvm::Module&) + 33
20 llc               0x000000000040ff57
21 llc               0x000000000040f0c2 main + 226
22 libc.so.6         0x00007f95a9f28de5 __libc_start_main + 245
23 llc               0x000000000040edc5
Stack dump:
0.    Program arguments: /home/jialiu01/llvm/review/build/bin/llc -O2
-mtriple=arm64-linux-gnueabi ff_i_g.ll 
1.    Running pass 'Function Pass Manager' on module 'ff_i_g.ll'.
2.    Running pass 'Machine InstCombiner' on function '@test_dgi'
Aborted (core dumped)</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>