<commit_before>#include <error.h>
#include <errno.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>

#include "common.h"

static feedback_t *feedback;
static pid_t mypid;

__attribute__ ((no_instrument_function)) __attribute__ ((constructor))
static void mapBB(void)
{
    mypid = getpid();
    if (mypid >= _HF_FEEDBACK_PID_SZ) {
        fprintf(stderr, "mypid > _HF_FEEDBACK_PID_SZ (%d > %d)\n", mypid, _HF_FEEDBACK_PID_SZ);
        _exit(1);
    }
    struct stat st;
    if (fstat(_HF_BITMAP_FD, &st) == -1) {
        fprintf(stderr, "fstat(%d): %s\n", _HF_BITMAP_FD, strerror(errno));
        _exit(1);
    }
    if (st.st_size != sizeof(feedback_t)) {
        fprintf(stderr, "st.size != sizeof(feedback_t) (%zu != %zu)\n", (size_t) st.st_size,
                sizeof(feedback_t));
        _exit(1);
    }
    if ((feedback =
         mmap(NULL, sizeof(feedback_t), PROT_READ | PROT_WRITE, MAP_SHARED, _HF_BITMAP_FD,
              0)) == MAP_FAILED) {
        fprintf(stderr, "mmap: %s\n", strerror(errno));
        _exit(1);
    }
    feedback->pidFeedback[mypid] = 0U;
}

__attribute__ ((no_instrument_function))
void __cyg_profile_func_enter(void *func, void *caller)
{
    register size_t pos =
        (((uintptr_t) func << 12) | ((uintptr_t) caller & 0xFFF)) & _HF_PERF_BITMAP_MASK;
    register size_t byteOff = pos / 8;<commit_msg>Enable fast optimizations for instrumentation<commit_after>#include <error.h>
#include <errno.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>

#include "common.h"

static feedback_t *feedback;
static pid_t mypid;

__attribute__ ((no_instrument_function)) __attribute__ ((constructor))
static void mapBB(void)
{
    mypid = getpid();
    if (mypid >= _HF_FEEDBACK_PID_SZ) {
        fprintf(stderr, "mypid > _HF_FEEDBACK_PID_SZ (%d > %d)\n", mypid, _HF_FEEDBACK_PID_SZ);
        _exit(1);
    }
    struct stat st;
    if (fstat(_HF_BITMAP_FD, &st) == -1) {
        fprintf(stderr, "fstat(%d): %s\n", _HF_BITMAP_FD, strerror(errno));
        _exit(1);
    }
    if (st.st_size != sizeof(feedback_t)) {
        fprintf(stderr, "st.size != sizeof(feedback_t) (%zu != %zu)\n", (size_t) st.st_size,
                sizeof(feedback_t));
        _exit(1);
    }
    if ((feedback =
         mmap(NULL, sizeof(feedback_t), PROT_READ | PROT_WRITE, MAP_SHARED, _HF_BITMAP_FD,
              0)) == MAP_FAILED) {
        fprintf(stderr, "mmap: %s\n", strerror(errno));
        _exit(1);
    }
    feedback->pidFeedback[mypid] = 0U;
}

/* This should be trully fast */

#ifdef __clang__
#pragma clang optimize on
#else
__attribute__((optimize("-Ofast")))
#endif
__attribute__ ((no_instrument_function))
void __cyg_profile_func_enter(void *func, void *caller)
{
    register size_t pos =
        (((uintptr_t) func << 12) | ((uintptr_t) caller & 0xFFF)) & _HF_PERF_BITMAP_MASK;
    register size_t byteOff = pos / 8;
{'fraction_non_alphanumeric': 0.15638766519823788, 'fraction_numerical': 0.006922592825676526, 'mean_word_length': 3.522048364153627, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6171944', 'n_tokens_mistral': 1286, 'n_tokens_neox': 1225, 'n_words': 249}