[sanitizer] Improve FreeBSD ASLR detection
[llvm-project.git] / llvm / tools / llvm-reduce / deltas / ReduceSpecialGlobals.cpp
blob57160f46ff8d9cde42d3b7e1f116ebebcfddd84b
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 "llvm/ADT/StringRef.h"
20 #include "llvm/IR/Constants.h"
21 #include "llvm/IR/GlobalValue.h"
23 using namespace llvm;
25 static StringRef SpecialGlobalNames[] = {"llvm.used", "llvm.compiler.used"};
27 /// Removes all special globals aren't inside any of the
28 /// desired Chunks.
29 static void extractSpecialGlobalsFromModule(Oracle &O, Module &Program) {
30 for (StringRef Name : SpecialGlobalNames) {
31 if (auto *Used = Program.getNamedGlobal(Name)) {
32 Used->replaceAllUsesWith(UndefValue::get(Used->getType()));
33 Used->eraseFromParent();
38 void llvm::reduceSpecialGlobalsDeltaPass(TestRunner &Test) {
39 errs() << "*** Reducing Special Globals ...\n";
40 runDeltaPass(Test, extractSpecialGlobalsFromModule);
41 errs() << "----------------------------\n";