1 //===- ReduceAliases.cpp - Specialized Delta Pass -------------------------===//
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-exception
7 //===----------------------------------------------------------------------===//
9 // This file implements a function which calls the Generic Delta pass in order
10 // to reduce aliases in the provided Module.
12 //===----------------------------------------------------------------------===//
14 #include "ReduceAliases.h"
17 #include "llvm/IR/Constants.h"
18 #include "llvm/IR/GlobalValue.h"
19 #include "llvm/Transforms/Utils/ModuleUtils.h"
23 /// Removes all aliases aren't inside any of the
25 static void extractAliasesFromModule(Oracle
&O
, ReducerWorkItem
&Program
) {
26 for (auto &GA
: make_early_inc_range(Program
.getModule().aliases())) {
27 if (!O
.shouldKeep()) {
28 GA
.replaceAllUsesWith(GA
.getAliasee());
34 static void extractIFuncsFromModule(Oracle
&O
, ReducerWorkItem
&WorkItem
) {
35 Module
&Mod
= WorkItem
.getModule();
37 std::vector
<GlobalIFunc
*> IFuncs
;
38 for (GlobalIFunc
&GI
: Mod
.ifuncs()) {
40 IFuncs
.push_back(&GI
);
44 lowerGlobalIFuncUsersAsGlobalCtor(Mod
, IFuncs
);
47 void llvm::reduceAliasesDeltaPass(TestRunner
&Test
) {
48 runDeltaPass(Test
, extractAliasesFromModule
, "Reducing Aliases");
51 void llvm::reduceIFuncsDeltaPass(TestRunner
&Test
) {
52 runDeltaPass(Test
, extractIFuncsFromModule
, "Reducing Ifuncs");