[flang][cuda] Add c_devloc as intrinsic and inline it during lowering (#120648)
[llvm-project.git] / llvm / tools / llvm-reduce / deltas / ReduceFunctionBodies.cpp
blob21875ba00cf8b23b2353572d7bdb6f8703499875
1 //===- ReduceFunctions.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 function bodies in the provided Module.
12 //===----------------------------------------------------------------------===//
14 #include "ReduceFunctionBodies.h"
15 #include "Delta.h"
16 #include "Utils.h"
17 #include "llvm/IR/GlobalValue.h"
18 #include "llvm/IR/Instructions.h"
20 using namespace llvm;
22 /// Removes all the bodies of defined functions that aren't inside any of the
23 /// desired Chunks.
24 static void extractFunctionBodiesFromModule(Oracle &O,
25 ReducerWorkItem &WorkItem) {
26 // Delete out-of-chunk function bodies
27 for (auto &F : WorkItem.getModule()) {
28 if (!F.isDeclaration() && !hasAliasUse(F) && !O.shouldKeep()) {
29 F.deleteBody();
30 F.setComdat(nullptr);
35 void llvm::reduceFunctionBodiesDeltaPass(TestRunner &Test) {
36 runDeltaPass(Test, extractFunctionBodiesFromModule,
37 "Reducing Function Bodies");
40 static void reduceFunctionData(Oracle &O, ReducerWorkItem &WorkItem) {
41 for (Function &F : WorkItem.getModule()) {
42 if (F.hasPersonalityFn()) {
43 if (none_of(F,
44 [](const BasicBlock &BB) {
45 return BB.isEHPad() || isa<ResumeInst>(BB.getTerminator());
46 }) &&
47 !O.shouldKeep()) {
48 F.setPersonalityFn(nullptr);
52 if (F.hasPrefixData() && !O.shouldKeep())
53 F.setPrefixData(nullptr);
55 if (F.hasPrologueData() && !O.shouldKeep())
56 F.setPrologueData(nullptr);
60 void llvm::reduceFunctionDataDeltaPass(TestRunner &Test) {
61 runDeltaPass(Test, reduceFunctionData, "Reducing Function Data");