LLVM: lib/Transforms/IPO/ExtractGV.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
16
17using namespace llvm;
18
19
20
21
22
25 if (Local || Delete) {
29 return;
30 }
31
34 return;
35 }
36
37
39 default:
43 return;
46 return;
47 }
48}
49
50
51
52
54 bool keepConstInit)
56 keepConstInit(keepConstInit) {}
57
59
60 if (!deleteStuff)
61 M.setModuleInlineAsm("");
62
63
64
65
66
67
68
69
70
72 bool Delete = deleteStuff == (bool)Named.count(&GV) &&
73 !GV.isDeclaration() && (!GV.isConstant() || !keepConstInit);
74 if (!Delete) {
75 if (GV.hasAvailableExternallyLinkage())
76 continue;
77 if (GV.getName() == "llvm.global_ctors")
78 continue;
79 }
80
82
83 if (Delete) {
84
85 GV.setInitializer(nullptr);
86 GV.setComdat(nullptr);
87 }
88 }
89
90
92 bool Delete = deleteStuff == (bool)Named.count(&F) && .isDeclaration();
93 if (!Delete) {
94 if (F.hasAvailableExternallyLinkage())
95 continue;
96 }
97
99
100 if (Delete) {
101
102 F.deleteBody();
103 F.setComdat(nullptr);
104 }
105 }
106
107
109 bool Delete = deleteStuff == (bool)Named.count(&GA);
111
112 if (Delete) {
113 Type *Ty = GA.getValueType();
114
115 GA.removeFromParent();
119 GA.getAddressSpace(), GA.getName(), &M);
120
121 } else {
124 }
126 delete &GA;
127 }
128 }
129
130
132 bool Delete = deleteStuff == (bool)Named.count(&IF);
134
135 if (!Delete)
136 continue;
137
139 IF.removeFromParent();
142 IF.getAddressSpace(), IF.getName(), &M);
143 IF.replaceAllUsesWith(Declaration);
144 delete &IF;
145 }
146
148}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Module.h This file contains the declarations for the Module class.
This header defines various interfaces for pass management in LLVM.
Class to represent function types.
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
bool hasLinkOnceLinkage() const
LinkageTypes getLinkage() const
bool hasLocalLinkage() const
void setLinkage(LinkageTypes LT)
@ HiddenVisibility
The GV is hidden.
void setVisibility(VisibilityTypes V)
static bool isDiscardableIfUnused(LinkageTypes Linkage)
Whether the definition of this global may be discarded if it is not used in its compilation unit.
@ LinkOnceAnyLinkage
Keep one copy of function when linking (inline)
@ WeakODRLinkage
Same, but only replaced by something equivalent.
@ ExternalLinkage
Externally visible function.
@ WeakAnyLinkage
Keep one copy of named function when linking (weak)
@ LinkOnceODRLinkage
Same, but only replaced by something equivalent.
A Module instance is used to store all the information related to an LLVM module.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM Value Representation.
LLVM_ABI void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast - Return the argument parameter cast to the specified type.
constexpr from_range_t from_range
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.