<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - Segfault during armv7 code generation for a PHINode referencing a call to llvm.frameaddress"
   href="https://bugs.llvm.org/show_bug.cgi?id=45327">45327</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Segfault during armv7 code generation for a PHINode referencing a call to llvm.frameaddress
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>10.0
          </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>enhancement
          </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>andrey.vihrov@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Consider the following LLVM IR (z.ll):
---------------------------------------------
define void @foo(i1, i8*) #0 {
E:
  br i1 %0, label %A, label %X

A:
  %a = call i8* @llvm.frameaddress(i32 0)
  br label %X

X:
  %p = phi i8* [ %a, %A ], [ %1, %E ]
  call void @bar(i8* %p)
  ret void
}

declare i8* @llvm.frameaddress(i32 immarg)

declare void @bar(i8*)

attributes #0 = { noinline optnone }
---------------------------------------------

Running
$ llc -mtriple=armv7-apple-ios z.ll
results in:

Stack dump:
0.      Program arguments: llvm-10.0.0/bin/llc -mtriple=armv7-apple-ios z.ll 
1.      Running pass 'Function Pass Manager' on module 'z.ll'.
2.      Running pass 'Live Variable Analysis' on function '@foo'
 #0 0x00007f06df2052da llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/tmp/llvm-10.0.0/bin/../lib/libLLVM-10.so+0x8532da)
 #1 0x00007f06df202f74 llvm::sys::RunSignalHandlers()
(/tmp/llvm-10.0.0/bin/../lib/libLLVM-10.so+0x850f74)
 #2 0x00007f06df2030b8 SignalHandler(int)
(/tmp/llvm-10.0.0/bin/../lib/libLLVM-10.so+0x8510b8)
 #3 0x00007f06de97a800 __restore_rt (/usr/lib/libpthread.so.0+0x14800)
 #4 0x00007f06df549ef0
llvm::LiveVariables::runOnBlock(llvm::MachineBasicBlock*, unsigned int)
(/tmp/llvm-10.0.0/bin/../lib/libLLVM-10.so+0xb97ef0)
 #5 0x00007f06df54d311
llvm::LiveVariables::runOnMachineFunction(llvm::MachineFunction&)
(/tmp/llvm-10.0.0/bin/../lib/libLLVM-10.so+0xb9b311)
 #6 0x00007f06df5c7461
llvm::MachineFunctionPass::runOnFunction(llvm::Function&)
(/tmp/llvm-10.0.0/bin/../lib/libLLVM-10.so+0xc15461)
 #7 0x00007f06df3554fa llvm::FPPassManager::runOnFunction(llvm::Function&)
(/tmp/llvm-10.0.0/bin/../lib/libLLVM-10.so+0x9a34fa)
 #8 0x00007f06df355ba1 llvm::FPPassManager::runOnModule(llvm::Module&)
(/tmp/llvm-10.0.0/bin/../lib/libLLVM-10.so+0x9a3ba1)
 #9 0x00007f06df355f39 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/tmp/llvm-10.0.0/bin/../lib/libLLVM-10.so+0x9a3f39)
#10 0x0000559e85629309 main (llvm-10.0.0/bin/llc+0x12309)
#11 0x00007f06de47e023 __libc_start_main (/usr/lib/libc.so.6+0x27023)
#12 0x0000559e8562a3ae _start (llvm-10.0.0/bin/llc+0x133ae)
Segmentation fault (core dumped)


Compiling with "-mtriple=thumbv7-apple-ios" produces the same result. At the
same time compilation succeeds with "-mtriple=aarch64-apple-ios",
"-mtriple=i386-apple-darwin" and "-mtriple=x86_64-apple-darwin". The crash is
also reproducible with "-mtriple=armv7-linux-androideabi", but not reproducible
with "-mtriple=armv7-none-eabi".

If the `llvm.frameaddress` is replaced by a different function, either regular
or another intrinsic like `llvm.returnaddress`, the error disappears. If the
`optnone` attribute is removed from the function `foo`, the error disappears.</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>