<commit_before>/*
 * Copyright (c) 2015-2016 <NAME>
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <libgen.h>
#include <unistd.h>
#include <sys/wait.h>
#include "cpp/cpp.h"
#include "shipping.h"
#include "hashtable.h"
#include "config.h"
#include "stringbuilder.h"
#include "threading.h"
#include "mempool.h"

extern Hashtable global_args;
typedef LLVMPassManagerBuilderRef LPMB;

static void shp_spawn_process(const char *process, const char *args[]);

void shp_optimize(LLVMModuleRef module)
{
    LPMB passBuilder = LLVMPassManagerBuilderCreate();
    LLVMPassManagerRef pm = LLVMCreatePassManager();
    LLVMTargetDataRef td = LLVMCreateTargetData("");

    unsigned opt = 0;

    // TODO: Find a workaround for these optimizations on 32 bit.
    if(LLVMPointerSize(td) >= 8)
    {
        opt = 2;

        if(IN(global_args, "-O0"))
            opt = 0;
        else if(IN(global_args, "-O1"))
            opt = 1;
        else if(IN(global_args, "-O3"))
            opt = 3;<commit_msg>Actually, actually address the problem<commit_after>/*
 * Copyright (c) 2015-2016 <NAME>
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <libgen.h>
#include <unistd.h>
#include <sys/wait.h>
#include "cpp/cpp.h"
#include "shipping.h"
#include "hashtable.h"
#include "config.h"
#include "stringbuilder.h"
#include "threading.h"
#include "mempool.h"

extern Hashtable global_args;
typedef LLVMPassManagerBuilderRef LPMB;

static void shp_spawn_process(const char *process, const char *args[]);

char *shp_get_data_rep()
{
    static char *ref;

    if(ref)
        return ref;

    LLVMTargetRef targ;
    LLVMGetTargetFromTriple(LLVMGetDefaultTargetTriple(), &targ, NULL);
    LLVMTargetMachineRef tm =
        LLVMCreateTargetMachine(targ, LLVMGetDefaultTargetTriple(),
                                "", "", LLVMCodeGenLevelNone,
                                LLVMRelocDefault, LLVMCodeModelDefault);

    LLVMTargetDataRef td = LLVMGetTargetMachineData(tm);
    ref = LLVMCopyStringRepOfTargetData(td);
    LLVMDisposeTargetMachine(tm);

    return ref;
}

void shp_optimize(LLVMModuleRef module)
{
    LPMB passBuilder = LLVMPassManagerBuilderCreate();
    LLVMPassManagerRef pm = LLVMCreatePassManager();
    LLVMTargetDataRef td = LLVMCreateTargetData(shp_get_data_rep());

    unsigned opt = 0;

    // TODO: Find a workaround for these optimizations on 32 bit.
    if(LLVMPointerSize(td) >= 8)
    {
        opt = 2;

        if(IN(global_args, "-O0"))
            opt = 0;
        else if(IN(global_args, "-O1"))
            opt = 1;
        else if(IN(global_args, "-O3"))
            opt = 3;
{'fraction_non_alphanumeric': 0.118378024852845, 'fraction_numerical': 0.015042511445389144, 'mean_word_length': 3.207702888583219, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2087669', 'n_tokens_mistral': 1089, 'n_tokens_neox': 1042, 'n_words': 275}