<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 - 'Can't simplify this node' when building ppc64_defconfig Linux kernel"
   href="https://bugs.llvm.org/show_bug.cgi?id=45301">45301</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>'Can't simplify this node' when building ppc64_defconfig Linux kernel
          </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>Windows NT
          </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>Backend: PowerPC
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>natechancellor@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, nemanja.i.ibm@gmail.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>When building the powerpc64 Linux kernel (ppc64_defconfig) with a build of LLVM
with assertions enabled:

$ curl -LSs <a href="https://git.kernel.org/torvalds/t/linux-5.6-rc7.tar.gz">https://git.kernel.org/torvalds/t/linux-5.6-rc7.tar.gz</a> | tar xzf -

$ cd linux-5.6-rc7

$ make -j$(nproc) -s ARCH=powerpc CC=clang CROSS_COMPILE=powerpc64-linux-gnu-
O=out/ppc64 distclean defconfig drivers/net/ethernet/emulex/benet/be_cmds.o
Can't simplify this node
UNREACHABLE executed at
/home/nathan/cbl/git/tc-build-master/llvm-project/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp:809!
Stack dump:
0.      Program arguments:
/home/nathan/cbl/git/tc-build-master/build/llvm/stage1/bin/clang-10 -cc1
-triple powerpc64-unknown-linux-gnu -S -disable-free -main-file-name be_cmds.c
-mrelocation-model static -mthread-model posix -fno-delete-null-pointer-checks
-mllvm -warn-stack-size=2048 -mframe-pointer=all -relaxed-aliasing -fmath-errno
-masm-verbose -no-integrated-as -mconstructor-aliases -fuse-init-array
-mcode-model large -target-cpu pwr5 -target-feature -altivec -target-feature
-vsx -target-feature -spe -target-feature -hard-float -msoft-float -mfloat-abi
soft -target-abi elfv1 -dwarf-column-info -debugger-tuning=gdb
-coverage-notes-file
/tmp/tmp.ioF70h70K2/linux-5.6-rc7/out/ppc64/drivers/net/ethernet/emulex/benet/be_cmds.gcno
-nostdsysteminc -nobuiltininc -resource-dir
/home/nathan/cbl/git/tc-build-master/build/llvm/stage1/lib/clang/10.0.0
-dependency-file drivers/net/ethernet/emulex/benet/.be_cmds.o.d -MT
drivers/net/ethernet/emulex/benet/be_cmds.o -sys-header-deps -isystem
/home/nathan/cbl/git/tc-build-master/build/llvm/stage1/lib/clang/10.0.0/include
-include /tmp/tmp.ioF70h70K2/linux-5.6-rc7/include/linux/kconfig.h -include
/tmp/tmp.ioF70h70K2/linux-5.6-rc7/include/linux/compiler_types.h -I
/tmp/tmp.ioF70h70K2/linux-5.6-rc7/arch/powerpc/include -I
./arch/powerpc/include/generated -I /tmp/tmp.ioF70h70K2/linux-5.6-rc7/include
-I ./include -I /tmp/tmp.ioF70h70K2/linux-5.6-rc7/arch/powerpc/include/uapi -I
./arch/powerpc/include/generated/uapi -I
/tmp/tmp.ioF70h70K2/linux-5.6-rc7/include/uapi -I ./include/generated/uapi -D
__KERNEL__ -I /tmp/tmp.ioF70h70K2/linux-5.6-rc7/arch/powerpc -D
HAVE_AS_ATHIGH=1 -D _TASK_CPU=300 -I
/tmp/tmp.ioF70h70K2/linux-5.6-rc7/drivers/net/ethernet/emulex/benet -I
./drivers/net/ethernet/emulex/benet -D MODULE -D KBUILD_BASENAME="be_cmds" -D
KBUILD_MODNAME="be2net" -O2 -Wall -Wundef -Werror=strict-prototypes
-Wno-trigraphs -Werror=implicit-function-declaration -Werror=implicit-int
-Wno-format-security -Werror=unknown-warning-option
-Wno-address-of-packed-member -Wno-format-invalid-specifier -Wno-gnu
-Wno-tautological-compare -Wno-unused-const-variable
-Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Werror=date-time
-Werror=incompatible-pointer-types -Wno-initializer-overrides -Wno-format
-Wno-sign-compare -Wno-format-zero-length -std=gnu89 -fno-dwarf-directory-asm
-fdebug-compilation-dir /tmp/tmp.ioF70h70K2/linux-5.6-rc7/out/ppc64
-ferror-limit 19 -fmessage-length 0 -pg -fwrapv -fno-signed-char
-fwchar-type=short -fno-signed-wchar -fobjc-runtime=gcc -fno-common
-fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp
-o /tmp/be_cmds-d1737c.s -x c
/tmp/tmp.ioF70h70K2/linux-5.6-rc7/drivers/net/ethernet/emulex/benet/be_cmds.c
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module
'/tmp/tmp.ioF70h70K2/linux-5.6-rc7/drivers/net/ethernet/emulex/benet/be_cmds.c'.
4.      Running pass 'PowerPC DAG->DAG Pattern Instruction Selection' on
function '@be_cmd_rss_config'
 #0 0x00000000025383b4 PrintStackTraceSignalHandler(void*)
(/home/nathan/cbl/git/tc-build-master/build/llvm/stage1/bin/clang-10+0x25383b4)
 #1 0x00000000025362ce llvm::sys::RunSignalHandlers()
(/home/nathan/cbl/git/tc-build-master/build/llvm/stage1/bin/clang-10+0x25362ce)
 #2 0x00000000025387c5 SignalHandler(int)
(/home/nathan/cbl/git/tc-build-master/build/llvm/stage1/bin/clang-10+0x25387c5)
 #3 0x00007f84b246c890 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12890)
 #4 0x00007f84b113fe97 raise (/lib/x86_64-linux-gnu/libc.so.6+0x3ee97)
 #5 0x00007f84b1141801 abort (/lib/x86_64-linux-gnu/libc.so.6+0x40801)
 #6 0x00000000024e2961
(/home/nathan/cbl/git/tc-build-master/build/llvm/stage1/bin/clang-10+0x24e2961)
 #7 0x00000000032b5371
llvm::TargetLowering::SimplifyDemandedBits(llvm::SDValue, llvm::APInt const&,
llvm::APInt const&, llvm::KnownBits&, llvm::TargetLowering::TargetLoweringOpt&,
unsigned int, bool) const
(/home/nathan/cbl/git/tc-build-master/build/llvm/stage1/bin/clang-10+0x32b5371)
 #8 0x00000000032ab6fd
llvm::TargetLowering::SimplifyDemandedBits(llvm::SDValue, llvm::APInt const&,
llvm::APInt const&, llvm::KnownBits&, llvm::TargetLowering::TargetLoweringOpt&,
unsigned int, bool) const
(/home/nathan/cbl/git/tc-build-master/build/llvm/stage1/bin/clang-10+0x32ab6fd)
 #9 0x00000000030e936b (anonymous
namespace)::DAGCombiner::SimplifyDemandedBits(llvm::SDValue, llvm::APInt
const&)
(/home/nathan/cbl/git/tc-build-master/build/llvm/stage1/bin/clang-10+0x30e936b)
#10 0x00000000030e537a (anonymous
namespace)::DAGCombiner::visitADDLike(llvm::SDNode*)
(/home/nathan/cbl/git/tc-build-master/build/llvm/stage1/bin/clang-10+0x30e537a)
#11 0x0000000003095244 (anonymous namespace)::DAGCombiner::visit(llvm::SDNode*)
(/home/nathan/cbl/git/tc-build-master/build/llvm/stage1/bin/clang-10+0x3095244)
#12 0x000000000308ffdc (anonymous
namespace)::DAGCombiner::combine(llvm::SDNode*)
(/home/nathan/cbl/git/tc-build-master/build/llvm/stage1/bin/clang-10+0x308ffdc)
#13 0x000000000308db26 llvm::SelectionDAG::Combine(llvm::CombineLevel,
llvm::AAResults*, llvm::CodeGenOpt::Level)
(/home/nathan/cbl/git/tc-build-master/build/llvm/stage1/bin/clang-10+0x308db26)
#14 0x00000000031f259a llvm::SelectionDAGISel::CodeGenAndEmitDAG()
(/home/nathan/cbl/git/tc-build-master/build/llvm/stage1/bin/clang-10+0x31f259a)
#15 0x00000000031f0502
llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&)
(/home/nathan/cbl/git/tc-build-master/build/llvm/stage1/bin/clang-10+0x31f0502)
#16 0x00000000031ece06
llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&)
(/home/nathan/cbl/git/tc-build-master/build/llvm/stage1/bin/clang-10+0x31ece06)
#17 0x000000000162e1a1 (anonymous
namespace)::PPCDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&)
(/home/nathan/cbl/git/tc-build-master/build/llvm/stage1/bin/clang-10+0x162e1a1)
#18 0x0000000001c1867e
llvm::MachineFunctionPass::runOnFunction(llvm::Function&)
(/home/nathan/cbl/git/tc-build-master/build/llvm/stage1/bin/clang-10+0x1c1867e)
#19 0x0000000001f9af89 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/home/nathan/cbl/git/tc-build-master/build/llvm/stage1/bin/clang-10+0x1f9af89)
#20 0x0000000001f9b3c8 llvm::FPPassManager::runOnModule(llvm::Module&)
(/home/nathan/cbl/git/tc-build-master/build/llvm/stage1/bin/clang-10+0x1f9b3c8)
#21 0x0000000001f9baf4 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/home/nathan/cbl/git/tc-build-master/build/llvm/stage1/bin/clang-10+0x1f9baf4)
#22 0x00000000026fc25e clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::HeaderSearchOptions const&, clang::CodeGenOptions const&,
clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout
const&, llvm::Module*, clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >)
(/home/nathan/cbl/git/tc-build-master/build/llvm/stage1/bin/clang-10+0x26fc25e)
#23 0x0000000002e1c1ca
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/home/nathan/cbl/git/tc-build-master/build/llvm/stage1/bin/clang-10+0x2e1c1ca)
#24 0x00000000034ebeb3 clang::ParseAST(clang::Sema&, bool, bool)
(/home/nathan/cbl/git/tc-build-master/build/llvm/stage1/bin/clang-10+0x34ebeb3)
#25 0x0000000002d88be0 clang::FrontendAction::Execute()
(/home/nathan/cbl/git/tc-build-master/build/llvm/stage1/bin/clang-10+0x2d88be0)
#26 0x0000000002cf32b2
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/nathan/cbl/git/tc-build-master/build/llvm/stage1/bin/clang-10+0x2cf32b2)
#27 0x0000000002e16cf4
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/nathan/cbl/git/tc-build-master/build/llvm/stage1/bin/clang-10+0x2e16cf4)
#28 0x000000000159dac9 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*)
(/home/nathan/cbl/git/tc-build-master/build/llvm/stage1/bin/clang-10+0x159dac9)
#29 0x0000000001599c8a main
(/home/nathan/cbl/git/tc-build-master/build/llvm/stage1/bin/clang-10+0x1599c8a)
#30 0x00007f84b1122b97 __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x21b97)
#31 0x0000000001598daa _start
(/home/nathan/cbl/git/tc-build-master/build/llvm/stage1/bin/clang-10+0x1598daa)
clang-10: error: unable to execute command: Aborted
clang-10: error: clang frontend command failed due to signal (use -v to see
invocation)

I bisected this down to 1b7b4b467f03322f37b20ccee5cdef0c9ecec5d4, which adds
the llvm_unreachable that this driver trips over.

creduce spits out:

a(void *b, int c) {
  int *d = b;
  do {
    *d = __builtin_constant_p(0)
             ? (*d & 255UL) << 24 | (*d & 65280UL) << 8 |
                   (*d & 16711680UL) >> 8 | (*d & 4278190080) >> 24
             : 0;
    d++;
    c -= 4;
  } while (c);
}
struct e {
  int f[10]
} g() {
  struct e *h = i();
  memcpy(h, g, 40);
  a(h, sizeof(h->f));
}

Full preprocessed file and interestingness test available at
<a href="https://github.com/nathanchance/creduce-files/tree/887a2dff5ee05d953b059cf6ac3ead478fa50ee6/ppc64-be_cmds">https://github.com/nathanchance/creduce-files/tree/887a2dff5ee05d953b059cf6ac3ead478fa50ee6/ppc64-be_cmds</a>.</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>