brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · 9d4a2a1 Raw
43 lines · cpp
1//===- ReduceAliases.cpp - Specialized Delta Pass -------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8//9// This file implements a function which calls the Generic Delta pass in order10// to reduce aliases in the provided Module.11//12//===----------------------------------------------------------------------===//13 14#include "ReduceAliases.h"15#include "llvm/IR/GlobalValue.h"16#include "llvm/Transforms/Utils/ModuleUtils.h"17 18using namespace llvm;19 20/// Removes all aliases aren't inside any of the21/// desired Chunks.22void llvm::reduceAliasesDeltaPass(Oracle &O, ReducerWorkItem &Program) {23  for (auto &GA : make_early_inc_range(Program.getModule().aliases())) {24    if (!O.shouldKeep()) {25      GA.replaceAllUsesWith(GA.getAliasee());26      GA.eraseFromParent();27    }28  }29}30 31void llvm::reduceIFuncsDeltaPass(Oracle &O, ReducerWorkItem &WorkItem) {32  Module &Mod = WorkItem.getModule();33 34  std::vector<GlobalIFunc *> IFuncs;35  for (GlobalIFunc &GI : Mod.ifuncs()) {36    if (!O.shouldKeep())37      IFuncs.push_back(&GI);38  }39 40  if (!IFuncs.empty())41    lowerGlobalIFuncUsersAsGlobalCtor(Mod, IFuncs);42}43