-
Notifications
You must be signed in to change notification settings - Fork 11.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clang 18 crashes if built with PGO #91041
Comments
Interesting. Does this also reproduce when using a different stage1 compiler (e.g. previous LLVM release). As a first step, we need to clarify if this is caused by a miscompile by the stage1 compiler or if there's some kind of bug in the code that's crashing. |
Tried to just use clang-17 in last cmake, got Rebuilding instrumented clang-18 using clang-17 now. Funny thing is that I got segmentation fault in lld-17, which I traced to option Edit: ok i'll first reduce original reproducer, right now it has a ton of options. |
I've reduced original repro to "gather some profiles", and then cmake -G Ninja /root/llvm-build/llvm-project/llvm \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=clang-18 \
-DCMAKE_CXX_COMPILER=clang++-18 \
-DCMAKE_C_FLAGS="-fstrict-vtable-pointers -O0 -Wno-backend-plugin -g" \
-DCMAKE_CXX_FLAGS="-fstrict-vtable-pointers -O0 -Wno-backend-plugin -g" \
-DCMAKE_INSTALL_PREFIX="/root/llvm-build/stage2-prof-use/install" \
-DLLVM_PROFDATA_FILE="/root/llvm-build/stage2-prof-gen/profiles/clang.profdata" \
-DLLVM_USE_LINKER=lld \
-DLLVM_ENABLE_PROJECTS='clang' \
-DLLVM_ENABLE_RUNTIMES='compiler-rt;libcxxabi;libcxx;libunwind' \
-DLLVM_ENABLE_ZLIB=FORCE_ON \
-DLLVM_ENABLE_ZSTD=FORCE_ON \
-DLLVM_ENABLE_BINDINGS=OFF \
-DLLVM_INCLUDE_BENCHMARKS=OFF \
-DLLVM_INCLUDE_EXAMPLES=OFF \
-DLLVM_INCLUDE_TESTS=OFF \
-DLLVM_TARGETS_TO_BUILD=X86
ninja install clang-18 is taken from LLVM apt repo for Ubuntu 20.04
Removing |
Until now I used profile created from 11k .profraw files, so I decided to try to reduce quantity of raw files. During this process I found a single .profraw which, if included to profile, makes PGO Clang crash. First I bisected number of profraw files, taking a prefix from sorted list. That process gave me number 1191 - Clang compiled with profile created from first 1190 profraw files does not crash. Then I created profile from that single profraw number 1191, and it crashed. 1 bad profraw out of 1200 seems pretty rare, thought I did not check remaining 9k profiles. Attaching both profraw file and generated profdata from it 91041_profdata.tar.gz. Everything is done using llvm-18 from official repo. With this, reproducer looks like this ROOT=/root/llvm-build
mkdir -p "${ROOT}" && cd "${ROOT}"
git clone -b llvmorg-18.1.5 --depth=1 https://github.com/llvm/llvm-project.git
mkdir -p build && cd build
# llvm-profdata-18 merge -output=bad.profdata default_4023465489017712588_0.profraw
cmake -G Ninja "${ROOT}/llvm-project/llvm" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=clang-18 \
-DCMAKE_CXX_COMPILER=clang++-18 \
-DCMAKE_C_FLAGS="-fstrict-vtable-pointers -O0 -Wno-backend-plugin -g" \
-DCMAKE_CXX_FLAGS="-fstrict-vtable-pointers -O0 -Wno-backend-plugin -g" \
-DCMAKE_INSTALL_PREFIX="${PWD}/install" \
-DLLVM_PROFDATA_FILE="bad.profdata" \
-DLLVM_USE_LINKER=lld \
-DLLVM_ENABLE_PROJECTS='clang' \
-DLLVM_ENABLE_RUNTIMES='compiler-rt;libcxxabi;libcxx;libunwind' \
-DLLVM_ENABLE_ZLIB=FORCE_ON \
-DLLVM_ENABLE_ZSTD=FORCE_ON \
-DLLVM_ENABLE_BINDINGS=OFF \
-DLLVM_INCLUDE_BENCHMARKS=OFF \
-DLLVM_INCLUDE_EXAMPLES=OFF \
-DLLVM_INCLUDE_TESTS=OFF \
-DLLVM_TARGETS_TO_BUILD=X86
ninja install # clang segfaults while compiling runtimes I noticed two kinds of stacktraces, they are pretty similar but still:
These stack traces should be more accurate than in initial post since I don't use any optimizations now. I also found another profraw file with exactly the same size which does not trigger the crash. Although now I understand that profraw size depends on counter values. Can be there any differences in profraw files besides counter values? Please let me know if I can do anything else here. Right now I'm out of ideas as someone who is not an LLVM developer. |
+1, encountering the same issue with LLVM17.0.2 on Windows, using ClangCL as Stage1, shipped with MSVC 2022 |
fyi @fhahn and CC @akyrtzi I suspect that part of the code is very broken (Maybe also #81967 ) |
I use tag
llvmorg-18.1.5
. Build without PGO works fine, then I gathered some IR profiles and tried to rebuild LLVM. It crashed while trying to build runtimes with what looked like the same error. I've taken one example source and ran it through cvise.The crash does not reproduce with clang built without PGO
Crash:
locale-8f8074.cpp
cmake command used to build crashing compiler
The crash does not reproduce when Clang is built without PGO. I can provide any additional files if needed.
I'll try to get rid of as much cmake arguments as possible next.
The text was updated successfully, but these errors were encountered: