<html>
    <head>
      <base href="https://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 --- - Segfault when globals reference constants when targeting OSX" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D23779&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=h5jamcC5JQdeR7XjzLS9795aD2VBLRxdCGn219RZW3A&s=StMOUiEKvDMmEh7bxrod6GbLz3xKH28BEmZDumJPNlY&e=">23779</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Segfault when globals reference constants when targeting OSX
          </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>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>alex@crichton.co
          </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>The following IR will cause `llc` to segfault when executed with no extra
arguments:


    target triple = "x86_64-apple-darwin"                                      
    @a = external global i8                   
    @b = internal unnamed_addr constant i8* @a
    @c = global i8** @b                       

Note that if the IR instead targets 64-bit linux the segfault does not happen.

the backtrace given is:

0  llc             0x00000000021f4c36
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 44
1  llc             0x00000000021f4f4b
2  llc             0x00000000021f3a4c
3  libpthread.so.0 0x00007f7ad0a59340
4  llc             0x0000000000dde9b0
5  llc             0x0000000001894131
6  llc             0x00000000018947b4
7  llc             0x000000000189486a
llvm::AsmPrinter::EmitGlobalConstant(llvm::Constant const*) + 96
8  llc             0x000000000188c853
llvm::AsmPrinter::EmitGlobalVariable(llvm::GlobalVariable const*) + 3241
9  llc             0x000000000188f3cf
llvm::AsmPrinter::doFinalization(llvm::Module&) + 237
10 llc             0x00000000021372f1
llvm::FPPassManager::doFinalization(llvm::Module&) + 83
11 llc             0x00000000021376eb
12 llc             0x0000000002137c1d
llvm::legacy::PassManagerImpl::run(llvm::Module&) + 249
13 llc             0x0000000002137e57
llvm::legacy::PassManager::run(llvm::Module&) + 39
14 llc             0x0000000000c3fea5
15 llc             0x0000000000c3ef50 main + 242
16 libc.so.6       0x00007f7acfa58ec5 __libc_start_main + 245
17 llc             0x0000000000c3bff9
Stack dump:
0.      Program arguments: ./Debug+Asserts/bin/llc
/home/alex/bugpoint-reduced-simplified.ll 
zsh: segmentation fault (core dumped)  ./Debug+Asserts/bin/llc
~/bugpoint-reduced-simplified.ll</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>