<commit_before>/*
 * Copyright 2010-2017 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.jetbrains.kotlin.backend.konan.llvm

import kotlinx.cinterop.*
import llvm.*
import org.jetbrains.kotlin.backend.common.descriptors.allParameters
import org.jetbrains.kotlin.backend.common.descriptors.isSuspend
import org.jetbrains.kotlin.backend.konan.Context
import org.jetbrains.kotlin.backend.konan.KonanConfigKeys
import org.jetbrains.kotlin.backend.konan.KonanPhase
import org.jetbrains.kotlin.backend.konan.library.LinkData
import org.jetbrains.kotlin.backend.konan.PhaseManager
import org.jetbrains.kotlin.backend.konan.descriptors.*
import org.jetbrains.kotlin.backend.konan.ir.*
import org.jetbrains.kotlin.backend.konan.TargetManager
import org.jetbrains.kotlin.backend.konan.library.KonanLibraryWriter
import org.jetbrains.kotlin.backend.konan.library.SplitLibraryWriter
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.IrStatement
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.descriptors.IrBuiltinOperatorDescriptorBase
import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.util.getArguments
import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid
import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
import org.jetbrains.kotlin.ir.visitors.acceptVoid
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.TypeUtils
import org.jetbrains.kotlin.types.typeUtil.isNothing
import org.jetbrains.kotlin.types.typeUtil.isPrimitiveNumberType
import org.jetbrains.kotlin.types.typeUtil.isTypeParameter
import org.jetbrains.kotlin.types.typeUtil.isUnit


internal fun emitLLVM(context: Context) {

        val config = context.config.configuration
        val irModule = context.irModule!!

        // Note that we don't set module target explicitly.
        // It is determined by the target of runtime.bc
        // (see Llvm class in ContextUtils)
        // Which in turn is determined by the clang flags
        // used to compile runtime.bc.
        val llvmModule = LLVMModuleCreateWithName("out")!! // TODO: dispose
        context.llvmModule = llvmModule
        context.debugInfo.builder = DICreateBuilder(llvmModule)
        context.llvmDeclarations = createLlvmDeclarations(context)

        val phaser = PhaseManager(context)

        phaser.phase(KonanPhase.RTTI) {
            irModule.acceptVoid(RTTIGeneratorVisitor(context))
        }

        generateDebugInfoHeader(context)

        phaser.phase(KonanPhase.CODEGEN) {
            irModule.acceptVoid(CodeGeneratorVisitor(context))
        }

        if (context.shouldContainDebugInfo()) {
            DIFinalize(context.debugInfo.builder)
        }
        
        if (!config.getBoolean(KonanConfigKeys.NOLINK)) {
            val program = config.get(KonanConfigKeys.PROGRAM_NAME)!!
            val output = "$program}.kt.bc"
            context.bitcodeFileName = output
<commit_msg>A minor typo in a file name construction.<commit_after>/*
 * Copyright 2010-2017 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.jetbrains.kotlin.backend.konan.llvm

import kotlinx.cinterop.*
import llvm.*
import org.jetbrains.kotlin.backend.common.descriptors.allParameters
import org.jetbrains.kotlin.backend.common.descriptors.isSuspend
import org.jetbrains.kotlin.backend.konan.Context
import org.jetbrains.kotlin.backend.konan.KonanConfigKeys
import org.jetbrains.kotlin.backend.konan.KonanPhase
import org.jetbrains.kotlin.backend.konan.library.LinkData
import org.jetbrains.kotlin.backend.konan.PhaseManager
import org.jetbrains.kotlin.backend.konan.descriptors.*
import org.jetbrains.kotlin.backend.konan.ir.*
import org.jetbrains.kotlin.backend.konan.TargetManager
import org.jetbrains.kotlin.backend.konan.library.KonanLibraryWriter
import org.jetbrains.kotlin.backend.konan.library.SplitLibraryWriter
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.IrStatement
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.descriptors.IrBuiltinOperatorDescriptorBase
import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.util.getArguments
import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid
import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
import org.jetbrains.kotlin.ir.visitors.acceptVoid
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.TypeUtils
import org.jetbrains.kotlin.types.typeUtil.isNothing
import org.jetbrains.kotlin.types.typeUtil.isPrimitiveNumberType
import org.jetbrains.kotlin.types.typeUtil.isTypeParameter
import org.jetbrains.kotlin.types.typeUtil.isUnit


internal fun emitLLVM(context: Context) {

        val config = context.config.configuration
        val irModule = context.irModule!!

        // Note that we don't set module target explicitly.
        // It is determined by the target of runtime.bc
        // (see Llvm class in ContextUtils)
        // Which in turn is determined by the clang flags
        // used to compile runtime.bc.
        val llvmModule = LLVMModuleCreateWithName("out")!! // TODO: dispose
        context.llvmModule = llvmModule
        context.debugInfo.builder = DICreateBuilder(llvmModule)
        context.llvmDeclarations = createLlvmDeclarations(context)

        val phaser = PhaseManager(context)

        phaser.phase(KonanPhase.RTTI) {
            irModule.acceptVoid(RTTIGeneratorVisitor(context))
        }

        generateDebugInfoHeader(context)

        phaser.phase(KonanPhase.CODEGEN) {
            irModule.acceptVoid(CodeGeneratorVisitor(context))
        }

        if (context.shouldContainDebugInfo()) {
            DIFinalize(context.debugInfo.builder)
        }
        
        if (!config.getBoolean(KonanConfigKeys.NOLINK)) {
            val program = config.get(KonanConfigKeys.PROGRAM_NAME)!!
            val output = "${program}.kt.bc"
            context.bitcodeFileName = output

{'fraction_non_alphanumeric': 0.08832969572474002, 'fraction_numerical': 0.0030812684555141866, 'mean_word_length': 4.022566086395874, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6725869', 'n_tokens_mistral': 2437, 'n_tokens_neox': 2284, 'n_words': 473}