<commit_before>//
// Copyright (c) 2008 Advanced Micro Devices, Inc. All rights reserved.
//
#include "top.hpp"
#include "opt_level.hpp"
#include "library.hpp"
#include "utils/options.hpp"
#include "llvm/Module.h"
#include "llvm/Analysis/Passes.h"
#include "llvm/DataLayout.h"
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
#include "llvm/LinkAllPasses.h"
#include "llvm/Transforms/IPO/AMDOptOptions.h"
#include "compiler_stage.hpp"
using namespace amdcl;
using namespace llvm;

void
OptLevel::setup(bool isGPU, uint32_t OptLevel)
{
  // Add an appropriate DataLayout instance for this module.
  Passes().add(new DataLayout(module_));
  fpasses_ = new FunctionPassManager(module_);
  fpasses_->add(new DataLayout(module_));

  PassManagerBuilder Builder;
  Builder.OptLevel = OptLevel;

  if (Options()->libraryType_ == amd::GPU_Library_HSAIL) {
    if (OptLevel == 0) return;
  }

  if (!Options()->oVariables->Inline) {
    // No inlining pass
  } else if (isGPU) {
#ifdef WITH_TARGET_HSAIL
    if (Options()->libraryType_ == amd::GPU_Library_HSAIL) {
      if (HLC_Experimental_Enable_Calls) {
        HLC_Disable_Amd_Inline_All = true;
      }
      // Always create Inliner regardless of OptLevel
      if (HLC_Force_Always_Inliner_Pass) {
        Builder.Inliner = createAlwaysInlinerPass();
      } else {
        Builder.Inliner = createFunctionInliningPass(500);
      }
    } else 
#endif
    {
      // Always create Inliner regardless of OptLevel
      Builder.Inliner = createFunctionInliningPass(500);
    }
  } else if (OptLevel > 1) {
    unsigned Threshold = 225;
    if (OptLevel > 2)
      Threshold = 275;
#ifdef WITH_TARGET_HSAIL
    if (Options()->libraryType_ == amd::GPU_Library_HSAIL) {
      // Don't do inlining (including createAlwaysInlinerPass()) if OptimizationLevel<commit_msg>P4 to Git Change 1082704 by s<EMAIL>@<EMAIL> on 2014/09/30 09:39:56<commit_after>//
// Copyright (c) 2008 Advanced Micro Devices, Inc. All rights reserved.
//
#include "top.hpp"
#include "opt_level.hpp"
#include "library.hpp"
#include "utils/options.hpp"
#include "llvm/Module.h"
#include "llvm/Analysis/Passes.h"
#include "llvm/DataLayout.h"
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
#include "llvm/LinkAllPasses.h"
#include "llvm/Transforms/IPO/AMDOptOptions.h"
#include "compiler_stage.hpp"
using namespace amdcl;
using namespace llvm;

void
OptLevel::setup(bool isGPU, uint32_t OptLevel)
{
  // Add an appropriate DataLayout instance for this module.
  Passes().add(new DataLayout(module_));
  fpasses_ = new FunctionPassManager(module_);
  fpasses_->add(new DataLayout(module_));

  PassManagerBuilder Builder;
  Builder.OptLevel = OptLevel;

  if (Options()->libraryType_ == amd::GPU_Library_HSAIL) {
    if (OptLevel == 0) return;
  }

  if (!Options()->oVariables->Inline) {
    // No inlining pass
  } else if (isGPU) {
#ifdef WITH_TARGET_HSAIL
    if (Options()->libraryType_ == amd::GPU_Library_HSAIL) {
      if (HLC_HSAIL_Enable_Calls) {
        HLC_Disable_Amd_Inline_All = true;
      }
      // Always create Inliner regardless of OptLevel
      if (HLC_Force_Always_Inliner_Pass) {
        Builder.Inliner = createAlwaysInlinerPass();
      } else {
        Builder.Inliner = createFunctionInliningPass(HLC_HSAIL_Inline_Threshold);
      }
    } else 
#endif
    {
      // Always create Inliner regardless of OptLevel
      Builder.Inliner = createFunctionInliningPass(500);
    }
  } else if (OptLevel > 1) {
    unsigned Threshold = 225;
    if (OptLevel > 2)
      Threshold = 275;
#ifdef WITH_TARGET_HSAIL
    if (Options()->libraryType_ == amd::GPU_Library_HSAIL) {
      // Don't do inlining (including createAlwaysInlinerPass()) if OptimizationLevel
{'fraction_non_alphanumeric': 0.11871281773931855, 'fraction_numerical': 0.016495402920497566, 'mean_word_length': 3.879947229551451, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, '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': '3388684', 'n_tokens_mistral': 1306, 'n_tokens_neox': 1221, 'n_words': 276}