[clang] Propagate -ftime-report to offload lto (#122143)
[llvm-project.git] / llvm / tools / llvm-reduce / deltas / ReduceGlobalVarInitializers.cpp
blob4c7125217f25209a94e1973e83dd75c59e8d16b6
1 //===- ReduceGlobalVars.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-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements a function which calls the Generic Delta pass in order
10 // to reduce initializers of Global Variables in the provided Module.
12 //===----------------------------------------------------------------------===//
14 #include "ReduceGlobalVarInitializers.h"
15 #include "llvm/IR/Constants.h"
16 #include "llvm/IR/GlobalValue.h"
18 using namespace llvm;
20 /// Removes all the Initialized GVs that aren't inside the desired Chunks.
21 static void extractGVsFromModule(Oracle &O, ReducerWorkItem &WorkItem) {
22 // Drop initializers of out-of-chunk GVs
23 for (auto &GV : WorkItem.getModule().globals())
24 if (GV.hasInitializer() && !O.shouldKeep()) {
25 GV.setInitializer(nullptr);
26 GV.setLinkage(GlobalValue::LinkageTypes::ExternalLinkage);
27 GV.setComdat(nullptr);
31 void llvm::reduceGlobalsInitializersDeltaPass(TestRunner &Test) {
32 runDeltaPass(Test, extractGVsFromModule, "Reducing GV Initializers");