[PATCH] D142535: [DAGCombine] Fold redundant select
Bogdan Graur via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 10 05:59:00 PST 2023
bgraur added a comment.
I tried myself to reproduce the miscompile building `clang` from the LLVM source tree using the `cmake` method and found out that it is important to use the standard library headers from the LLVM sources and not the system headers which may be an older version.
Here's the steps that worked for me:
cd $LLVM_ROOT
$ mkdir build && cd build
$ cmake -G "Ninja" \
-DCMAKE_INSTALL_PREFIX=$LLVM_ROOT/install \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_PROJECTS="clang" \
-DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \
../llvm
$ cmake --build .
$ cmake --install .
# Check how the compiler is invoked and what include paths are used for the standard headers:
$ ./bin/clang -O3 \
-o /tmp/miscompile \
miscompile.cc -lc++ -Llib/x86_64-unknown-linux-gnu/ -###
# Replace the system path `/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12` with `$LLVM_ROOT/install/include/c++/v1`
# Replace the system path `/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/x86_64-linux-gnu/c++/12` with `$LLVM_ROOT/install/include/x86_64-unknown-linux-gnu/c++/v1`
# Execute the resulting command, it should look similar to:
$ "/usr/local/google/home/bgraur/work/llvm-project/install/bin/clang-17" \
"-cc1" "-triple" "x86_64-unknown-linux-gnu" "-emit-obj" "-disable-free" \
"-clear-ast-before-backend" "-disable-llvm-verifier" "-discard-value-names" \
"-main-file-name" "miscompile.cc" "-mrelocation-model" "pic" "-pic-level" "2" \
"-pic-is-pie" "-mframe-pointer=none" "-fmath-errno" "-ffp-contract=on" \
"-fno-rounding-math" "-mconstructor-aliases" "-funwind-tables=2" \
"-target-cpu" "x86-64" "-tune-cpu" "generic" "-mllvm" "-treat-scalable-fixed-error-as-warning" \
"-debugger-tuning=gdb" "-fcoverage-compilation-dir=$LLVM_ROOT/install" \
"-resource-dir" "/usr/local/google/home/bgraur/work/llvm-project/install/lib/clang/17" \
"-internal-isystem" "$LLVM_ROOT/install/include/c++/v1" \
"-internal-isystem" "$LLVM_ROOT/install/include/x86_64-unknown-linux-gnu/c++/v1" \
"-internal-isystem" "/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/backward" \
"-internal-isystem" "$LLVM_ROOT/install/lib/clang/17/include" \
"-internal-isystem" "/usr/local/include" "-internal-isystem" \
"/usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include" \
"-internal-externc-isystem" "/usr/include/x86_64-linux-gnu" \
"-internal-externc-isystem" "/include" "-internal-externc-isystem" "/usr/include" \
"-O3" "-fdeprecated-macro" "-fdebug-compilation-dir=$LLVM_ROOT/install" \
"-ferror-limit" "19" "-fgnuc-version=4.2.1" "-fcxx-exceptions" "-fexceptions" \
"-fcolor-diagnostics" "-vectorize-loops" "-vectorize-slp" "-faddrsig" \
"-D__GCC_HAVE_DWARF2_CFI_ASM=1" \
"-o" "/tmp/miscompile-c4b187.o" "-x" "c++" "../miscompile/miscompile.cc"
# Run the linker command (no changes should be necessary).
The resulting binary should show the issue.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D142535/new/
https://reviews.llvm.org/D142535
More information about the llvm-commits
mailing list