<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 --- - Compiling kernel bpf samples with -O0 results in error"
   href="https://llvm.org/bugs/show_bug.cgi?id=26108">26108</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Compiling kernel bpf samples with -O0 results in error
          </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>prb003@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>compiling samples/bpf/ from linux kernel with change in optimization as -O0
results in following error. Though with -O2 (which is default in Makefile)
works fine.

$ make samples/bpf/
[...]
clang  -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/4.9/include
-I./arch/x86/include -Iarch/x86/include/generated/uapi
-Iarch/x86/include/generated  -Iinclude -I./arch/x86/include/uapi
-Iarch/x86/include/generated/uapi -I./include/uapi -Iinclude/generated/uapi
-include ./include/linux/kconfig.h  \
    -D__KERNEL__ -Wno-unused-value -Wno-pointer-sign \
    -O0 -emit-llvm -c samples/bpf/tracex1_kern.c -o -| /home/ravi/bin/llc
-march=bpf -filetype=obj -o samples/bpf/tracex1_kern.o
LLVM ERROR: Cannot select: t12: ch,glue = BPFISD::CALL t11, t6, Register:i64
%R1, t11:1
  t6: i64,ch = load<LD8[getelementptr inbounds (%struct.smp_ops,
%struct.smp_ops* @smp_ops, i32 0, i32 3)]> t0, t3, undef:i64
    t3: i64 = add t16, Constant:i64<24>
      t16: i64 = BPFISD::Wrapper TargetGlobalAddress:i64<%struct.smp_ops*
@smp_ops> 0
        t15: i64 = TargetGlobalAddress<%struct.smp_ops* @smp_ops> 0
      t2: i64 = Constant<24>
    t5: i64 = undef
  t10: i64 = Register %R1
  t11: ch,glue = CopyToReg t9, Register:i64 %R1, Constant:i64<0>
    t10: i64 = Register %R1
    t4: i64 = Constant<0>
In function: smp_send_stop
samples/bpf/Makefile:66: recipe for target 'samples/bpf/tracex1_kern.o' failed
make[1]: *** [samples/bpf/tracex1_kern.o] Error 1
Makefile:1544: recipe for target 'samples/bpf/' failed
make: *** [samples/bpf/] Error 2
$

Experimented on,
Linux kernel version : 4.4
Architecture : x86
clang version : 3.8.0 (trunk 256744)
llc version : 3.8.0svn</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>