Skip to content

CReduce stucked on reduction based on tests about LLVM stats. #272

@khei4

Description

@khei4

By following an interesting test, I tried to reduce the instrumented CSmith output for x86 with avx512f based on the loop-vectorize stats.

#!/bin/bash

# Define variables for paths
COMPILER_PATH=/home/khei4/git/llvm-project/build/bin/clang
PROGRAM_PATH=/home/khei4/git/VecFuzz/preproced2.c
CSMITH_INCLUDE_PATH=/home/khei4/git/VecFuzz/csmith/include

$COMPILER_PATH $PROGRAM_PATH -S -o tmp.s \
    -isystem$CSMITH_INCLUDE_PATH -std=c23 \
    -O3 -target x86_64-pc-linux-gnu -mavx512f -mllvm -stats \
    -emit-llvm -Wno-everything -mllvm -slp-threshold=-100 2>&1 | grep "5 loop-vectorize"

This script itself runs fine for the input

$ ./reduction_stats_x86.sh 
    5 loop-vectorize               - Number of loops vectorized

However, CReduce seems to have failed to keep that test and got stuck during the reduction.

$ creduce reduction_stats_x86.sh preproced2.c --n 1
===< 2057732 >===
running 1 interestingness test in parallel
===< pass_unifdef :: 0 >===
===< pass_comments :: 0 >===
===< pass_ifs :: 0 >===
===< pass_includes :: 0 >===
===< pass_line_markers :: 0 >===
(5.2 %, 231911 bytes)
===< pass_blank :: 0 >===
(5.8 %, 230508 bytes)
(5.8 %, 230455 bytes)
===< pass_clang_binsrch :: replace-function-def-with-decl >===
===< pass_clang_binsrch :: remove-unused-function >=== # stucked

Seems like the intermediate result doesn't pass the test already. (is this normal?)

$ ./reduction_stats_x86.sh # executed while the above reduction was running
$ echo $?
1

Am I wrong for writing a test script? If you need some required info, I'd be happy if you tell me. Thanks!

Environment

/home/khei4/git/llvm-project/build/bin/clang --version
clang version 18.0.0 (https://github.com/khei4/llvm-project.git 5d59e97e883445f36e99d4b9600330ac4a631565)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/khei4/git/llvm-project/build/bin
$ cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.6 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.6 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

CReduce is installed by apt.

$ creduce --version
creduce 2.11.0 (unknown)
Original motivation

I wanted to reduce instrumented CSmith output while keeping the stats about vectorization for two targets as the following shell script tests, but even for the partial test, the reduction didn't succeed.

#!/bin/bash

# Define variables for paths
COMPILER_PATH=/home/khei4/git/llvm-project/build/bin/clang
PROGRAM_PATH=/home/khei4/git/VecFuzz/preproced2.c
CSMITH_INCLUDE_PATH=/home/khei4/git/VecFuzz/csmith/include
ARCH64_INCLUDE_PATH=/usr/aarch64-linux-gnu/include

# First compilation for aarch64
$COMPILER_PATH $PROGRAM_PATH -S -o tmp.s \
    -isystem$CSMITH_INCLUDE_PATH \
    -isystem$ARCH64_INCLUDE_PATH -std=c23 -O3 -target \
    aarch64 -march=armv8.5-a+sve -msve-vector-bits=512 -mllvm -stats \
    -emit-llvm -Wno-everything -mllvm -slp-threshold=-100 2>&1 | grep "4 loop-vectorize" &&
# Second compilation for x86_64
$COMPILER_PATH $PROGRAM_PATH -S -o tmp.s \
    -isystem$CSMITH_INCLUDE_PATH -std=c23 \
    -O3 -target x86_64-pc-linux-gnu -mavx512f -mllvm -stats \
    -emit-llvm -Wno-everything -mllvm -slp-threshold=-100 2>&1 | grep "5 loop-vectorize"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions