[clang] Propagate -ftime-report to offload lto (#122143)
[llvm-project.git] / llvm / tools / llvm-reduce / deltas / ReduceSpecialGlobals.cpp
blobaadd038033d5c003acc09273b3dd955975afe2e4
1 //===- ReduceSpecialGlobals.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 special globals, like @llvm.used, in the provided Module.
12 // For more details about special globals, see
13 // https://llvm.org/docs/LangRef.html#intrinsic-global-variables
15 //===----------------------------------------------------------------------===//
17 #include "ReduceSpecialGlobals.h"
18 #include "Delta.h"
19 #include "Utils.h"
20 #include "llvm/ADT/StringRef.h"
21 #include "llvm/IR/Constants.h"
22 #include "llvm/IR/GlobalValue.h"
24 using namespace llvm;
26 static StringRef SpecialGlobalNames[] = {"llvm.used", "llvm.compiler.used"};
28 /// Removes all special globals aren't inside any of the
29 /// desired Chunks.
30 static void extractSpecialGlobalsFromModule(Oracle &O,
31 ReducerWorkItem &WorkItem) {
32 Module &Program = WorkItem.getModule();
34 for (StringRef Name : SpecialGlobalNames) {
35 if (auto *Used = Program.getNamedGlobal(Name)) {
36 if (!O.shouldKeep()) {
37 Used->replaceAllUsesWith(getDefaultValue(Used->getType()));
38 Used->eraseFromParent();
44 void llvm::reduceSpecialGlobalsDeltaPass(TestRunner &Test) {
45 runDeltaPass(Test, extractSpecialGlobalsFromModule,
46 "Reducing Special Globals");