Skip to content

clang 19 or 20 miscompiles llvm::MergeBasicBlockIntoOnlyPred for PPC32 #133507

Open
@kernigh

Description

@kernigh

For target powerpc-unknown-openbsd, clang-19 or clang-20 miscompiles the function llvm::MergeBasicBlockIntoOnlyPred in llvm 19. clang-18 works. This means that clang-19 miscompiles itself for 32-bit PowerPC. If my target clang-19 contains a miscompiled MergeBasicBlockIntoOnlyPred, then it will (with most .c files) either crash SIGSEGV or get stuck in an infinite loop.

My target clang-19's source tree has a few modifications. One of them moves MergeBasicBlockIntoOnlyPred from llvm/lib/Transforms/Utils/Local.cpp to its own file. The attached emini.zip contains

  • emini.cpp, a MergeBasicBlockIntoOnlyPred preprocessed by clang-16 with OpenBSD/macppc headers.
  • ecompile.sh, a script to cross-compile emini.cpp,

$ sh ecompile.sh -c emini.cpp -o whatever.o

You can build emini.cpp with clang 16 to 20. It doesn't work with git main, because clang-21 seems to drop support for __is_referencable in my libc++ headers.

I have started a git bisect of llvm-project on my fast AMD64 machine. I can cross-compile emini.cpp on the AMD64 and copy the .o to my slow PPC32 machine, where I link it into my target clang-19, then try to compile and run OpenBSD date(1) with my target clang-19. If it works, git bisect good. If it crashes or times out, git bisect bad. I know that releases/20.x is bad and releases/18.x is good. I need about 2 hours to build each git commit, so I might take a few more days to finish my bisect.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions