<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 --- - [Linux kernel] crash when building kernel/rcu/tree.c with optimize and debug flags together"
   href="http://llvm.org/bugs/show_bug.cgi?id=22587">22587</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[Linux kernel] crash when building kernel/rcu/tree.c with optimize and debug flags together
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </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>-New Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>viniciustinti@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=13863" name="attach_13863" title="Original files and commands described in the bug report.">attachment 13863</a> <a href="attachment.cgi?id=13863&action=edit" title="Original files and commands described in the bug report.">[details]</a></span>
Original files and commands described in the bug report.

Clang crashes when building rcu_init_geometry() when using "-g -O2" flags
together. If these flags are removed the code is built successfully.

These bug was notice on r229242 (not sure if is when it happened).
By the LLVMLinux buildbot logs the r229167 does not have this problem. 

==== build command ====
clang-3.7 -cc1 -triple armv7--linux-gnueabihf -S -g -O2 -Wall -o tree.s -x c
tree-minimal.c

==== minimal crash tree.c able to crash ====
static int num_rcu_lvl[] = { 1, (4), 0, 0, 0, };
extern int rcu_num_nodes;
int rcu_num_nodes __attribute__((__section__(".data..read_mostly"))) = ((1 +
(4) + 0 + 0 + 0) - 4);

static void __attribute__ ((__section__(".init.text")))
__attribute__((no_instrument_function)) rcu_init_geometry(void)
{
 int i;
 int j;
 int rcu_capacity[4 + 1];

 for (i = 1; i <= 4; i++)
   for (j = 0; j <= i; j++)
    num_rcu_lvl[j] =
     (((1) + (rcu_capacity[i - j]) - 1) / (rcu_capacity[i - j]));

 rcu_num_nodes = 0;
 for (i = 0; i <= 4; i++)
  rcu_num_nodes += num_rcu_lvl[i];
}

void __attribute__ ((__section__(".init.text")))
__attribute__((no_instrument_function)) rcu_init(void)
{
 rcu_init_geometry();
}

==== crash ====
0  clang-3.7       0x00000000010035c8 llvm::sys::PrintStackTrace(_IO_FILE*) +
40
1  clang-3.7       0x00000000010046ab
2  libpthread.so.0 0x00007fbeda4b2340
3  clang-3.7       0x0000000000af7f44
llvm::MemoryDependenceAnalysis::getPointerDependencyFrom(llvm::AliasAnalysis::Location
const&, bool, llvm::ilist_iterator<llvm::Instruction>, llvm::BasicBlock*,
llvm::Instruction*) + 212
4  clang-3.7       0x0000000000af887c
llvm::MemoryDependenceAnalysis::getDependency(llvm::Instruction*) + 444
5  clang-3.7       0x0000000000f17447
6  clang-3.7       0x0000000000da53eb
llvm::FPPassManager::runOnFunction(llvm::Function&) + 315
7  clang-3.7       0x0000000001634165
8  clang-3.7       0x0000000000da5a1b
llvm::legacy::PassManagerImpl::run(llvm::Module&) + 859
9  clang-3.7       0x00000000013ba2a3
clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::CodeGenOptions
const&, clang::TargetOptions const&, clang::LangOptions const&,
llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::raw_ostream*) +
7827
10 clang-3.7       0x00000000013b05ce
11 clang-3.7       0x0000000001889f33 clang::ParseAST(clang::Sema&, bool, bool)
+ 467
12 clang-3.7       0x00000000013af59c clang::CodeGenAction::ExecuteAction() +
76
13 clang-3.7       0x000000000117b169 clang::FrontendAction::Execute() + 57
14 clang-3.7       0x000000000114c863
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 803
15 clang-3.7       0x00000000011edbf5
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 3141
16 clang-3.7       0x000000000068a89a cc1_main(llvm::ArrayRef<char const*>,
char const*, void*) + 602
17 clang-3.7       0x0000000000689c79 main + 11721
18 libc.so.6       0x00007fbed96c4ec5 __libc_start_main + 245
19 clang-3.7       0x0000000000686da9
Stack dump:
0.    Program arguments:
/home/tinti/Works/LLVMLinux/llvmlinux/toolchain/clang/head/install/bin/clang-3.7
-cc1 -triple armv7--linux-gnueabihf -S -g -O2 -Wall -o
/home/tinti//Works/LLVMLinux/work/crash_percpu/tree.s -x c
/home/tinti/Works/LLVMLinux/work/crash_percpu/tree-minimal.c 
1.    <eof> parser at end of file
2.    Per-module optimization passes
3.    Running pass 'CallGraph Pass Manager' on module
'/home/tinti/Works/LLVMLinux/work/crash_percpu/tree-minimal.c'.
4.    Running pass 'Dead Store Elimination' on function '@rcu_init_geometry'
tree-minimal.sh: line 1: 21896 Segmentation fault      (core dumped)
/home/tinti/Works/LLVMLinux/llvmlinux/toolchain/clang/head/install/bin/clang-3.7
-cc1 -triple armv7--linux-gnueabihf -S -g -O2 -Wall -o
/home/tinti//Works/LLVMLinux/work/crash_percpu/tree.s -x c
/home/tinti/Works/LLVMLinux/work/crash_percpu/tree-minimal.c</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>