LLVM  16.0.0git
StripSymbols.cpp
Go to the documentation of this file.
1 //===- StripSymbols.cpp - Strip symbols and debug info from a module ------===//
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 // The StripSymbols transformation implements code stripping. Specifically, it
10 // can delete:
11 //
12 // * names for virtual registers
13 // * symbols for internal globals and functions
14 // * debug information
15 //
16 // Note that this transformation makes code much less readable, so it should
17 // only be used in situations where the 'strip' utility would be used, such as
18 // reducing code size or making it harder to reverse engineer code.
19 //
20 //===----------------------------------------------------------------------===//
21 
23 #include "llvm/ADT/SmallPtrSet.h"
24 #include "llvm/IR/Constants.h"
25 #include "llvm/IR/DebugInfo.h"
26 #include "llvm/IR/DerivedTypes.h"
27 #include "llvm/IR/InstIterator.h"
28 #include "llvm/IR/Instructions.h"
29 #include "llvm/IR/Module.h"
30 #include "llvm/IR/PassManager.h"
31 #include "llvm/IR/TypeFinder.h"
33 #include "llvm/InitializePasses.h"
34 #include "llvm/Pass.h"
35 #include "llvm/Transforms/IPO.h"
37 
38 using namespace llvm;
39 
40 namespace {
41  class StripSymbols : public ModulePass {
42  bool OnlyDebugInfo;
43  public:
44  static char ID; // Pass identification, replacement for typeid
45  explicit StripSymbols(bool ODI = false)
46  : ModulePass(ID), OnlyDebugInfo(ODI) {
48  }
49 
50  bool runOnModule(Module &M) override;
51 
52  void getAnalysisUsage(AnalysisUsage &AU) const override {
53  AU.setPreservesAll();
54  }
55  };
56 
57  class StripNonDebugSymbols : public ModulePass {
58  public:
59  static char ID; // Pass identification, replacement for typeid
60  explicit StripNonDebugSymbols()
61  : ModulePass(ID) {
63  }
64 
65  bool runOnModule(Module &M) override;
66 
67  void getAnalysisUsage(AnalysisUsage &AU) const override {
68  AU.setPreservesAll();
69  }
70  };
71 
72  class StripDebugDeclare : public ModulePass {
73  public:
74  static char ID; // Pass identification, replacement for typeid
75  explicit StripDebugDeclare()
76  : ModulePass(ID) {
78  }
79 
80  bool runOnModule(Module &M) override;
81 
82  void getAnalysisUsage(AnalysisUsage &AU) const override {
83  AU.setPreservesAll();
84  }
85  };
86 
87  class StripDeadDebugInfo : public ModulePass {
88  public:
89  static char ID; // Pass identification, replacement for typeid
90  explicit StripDeadDebugInfo()
91  : ModulePass(ID) {
93  }
94 
95  bool runOnModule(Module &M) override;
96 
97  void getAnalysisUsage(AnalysisUsage &AU) const override {
98  AU.setPreservesAll();
99  }
100  };
101 }
102 
103 char StripSymbols::ID = 0;
104 INITIALIZE_PASS(StripSymbols, "strip",
105  "Strip all symbols from a module", false, false)
106 
107 ModulePass *llvm::createStripSymbolsPass(bool OnlyDebugInfo) {
108  return new StripSymbols(OnlyDebugInfo);
109 }
110 
111 char StripNonDebugSymbols::ID = 0;
112 INITIALIZE_PASS(StripNonDebugSymbols, "strip-nondebug",
113  "Strip all symbols, except dbg symbols, from a module",
114  false, false)
115 
117  return new StripNonDebugSymbols();
118 }
119 
120 char StripDebugDeclare::ID = 0;
121 INITIALIZE_PASS(StripDebugDeclare, "strip-debug-declare",
122  "Strip all llvm.dbg.declare intrinsics", false, false)
123 
125  return new StripDebugDeclare();
126 }
127 
128 char StripDeadDebugInfo::ID = 0;
129 INITIALIZE_PASS(StripDeadDebugInfo, "strip-dead-debug-info",
130  "Strip debug info for unused symbols", false, false)
131 
133  return new StripDeadDebugInfo();
134 }
135 
136 /// OnlyUsedBy - Return true if V is only used by Usr.
137 static bool OnlyUsedBy(Value *V, Value *Usr) {
138  for (User *U : V->users())
139  if (U != Usr)
140  return false;
141 
142  return true;
143 }
144 
146  assert(C->use_empty() && "Constant is not dead!");
148  for (Value *Op : C->operands())
149  if (OnlyUsedBy(Op, C))
150  Operands.insert(cast<Constant>(Op));
151  if (GlobalVariable *GV = dyn_cast<GlobalVariable>(C)) {
152  if (!GV->hasLocalLinkage()) return; // Don't delete non-static globals.
153  GV->eraseFromParent();
154  } else if (!isa<Function>(C)) {
155  // FIXME: Why does the type of the constant matter here?
156  if (isa<StructType>(C->getType()) || isa<ArrayType>(C->getType()) ||
157  isa<VectorType>(C->getType()))
158  C->destroyConstant();
159  }
160 
161  // If the constant referenced anything, see if we can delete it as well.
162  for (Constant *O : Operands)
164 }
165 
166 // Strip the symbol table of its names.
167 //
168 static void StripSymtab(ValueSymbolTable &ST, bool PreserveDbgInfo) {
169  for (ValueSymbolTable::iterator VI = ST.begin(), VE = ST.end(); VI != VE; ) {
170  Value *V = VI->getValue();
171  ++VI;
172  if (!isa<GlobalValue>(V) || cast<GlobalValue>(V)->hasLocalLinkage()) {
173  if (!PreserveDbgInfo || !V->getName().startswith("llvm.dbg"))
174  // Set name to "", removing from symbol table!
175  V->setName("");
176  }
177  }
178 }
179 
180 // Strip any named types of their names.
181 static void StripTypeNames(Module &M, bool PreserveDbgInfo) {
182  TypeFinder StructTypes;
183  StructTypes.run(M, false);
184 
185  for (StructType *STy : StructTypes) {
186  if (STy->isLiteral() || STy->getName().empty()) continue;
187 
188  if (PreserveDbgInfo && STy->getName().startswith("llvm.dbg"))
189  continue;
190 
191  STy->setName("");
192  }
193 }
194 
195 /// Find values that are marked as llvm.used.
196 static void findUsedValues(GlobalVariable *LLVMUsed,
198  if (!LLVMUsed) return;
199  UsedValues.insert(LLVMUsed);
200 
201  ConstantArray *Inits = cast<ConstantArray>(LLVMUsed->getInitializer());
202 
203  for (unsigned i = 0, e = Inits->getNumOperands(); i != e; ++i)
204  if (GlobalValue *GV =
205  dyn_cast<GlobalValue>(Inits->getOperand(i)->stripPointerCasts()))
206  UsedValues.insert(GV);
207 }
208 
209 /// StripSymbolNames - Strip symbol names.
210 static bool StripSymbolNames(Module &M, bool PreserveDbgInfo) {
211 
212  SmallPtrSet<const GlobalValue*, 8> llvmUsedValues;
213  findUsedValues(M.getGlobalVariable("llvm.used"), llvmUsedValues);
214  findUsedValues(M.getGlobalVariable("llvm.compiler.used"), llvmUsedValues);
215 
216  for (GlobalVariable &GV : M.globals()) {
217  if (GV.hasLocalLinkage() && !llvmUsedValues.contains(&GV))
218  if (!PreserveDbgInfo || !GV.getName().startswith("llvm.dbg"))
219  GV.setName(""); // Internal symbols can't participate in linkage
220  }
221 
222  for (Function &I : M) {
223  if (I.hasLocalLinkage() && !llvmUsedValues.contains(&I))
224  if (!PreserveDbgInfo || !I.getName().startswith("llvm.dbg"))
225  I.setName(""); // Internal symbols can't participate in linkage
226  if (auto *Symtab = I.getValueSymbolTable())
227  StripSymtab(*Symtab, PreserveDbgInfo);
228  }
229 
230  // Remove all names from types.
231  StripTypeNames(M, PreserveDbgInfo);
232 
233  return true;
234 }
235 
236 bool StripSymbols::runOnModule(Module &M) {
237  if (skipModule(M))
238  return false;
239 
240  bool Changed = false;
241  Changed |= StripDebugInfo(M);
242  if (!OnlyDebugInfo)
243  Changed |= StripSymbolNames(M, false);
244  return Changed;
245 }
246 
247 bool StripNonDebugSymbols::runOnModule(Module &M) {
248  if (skipModule(M))
249  return false;
250 
251  return StripSymbolNames(M, true);
252 }
253 
254 static bool stripDebugDeclareImpl(Module &M) {
255 
256  Function *Declare = M.getFunction("llvm.dbg.declare");
257  std::vector<Constant*> DeadConstants;
258 
259  if (Declare) {
260  while (!Declare->use_empty()) {
261  CallInst *CI = cast<CallInst>(Declare->user_back());
262  Value *Arg1 = CI->getArgOperand(0);
263  Value *Arg2 = CI->getArgOperand(1);
264  assert(CI->use_empty() && "llvm.dbg intrinsic should have void result");
265  CI->eraseFromParent();
266  if (Arg1->use_empty()) {
267  if (Constant *C = dyn_cast<Constant>(Arg1))
268  DeadConstants.push_back(C);
269  else
271  }
272  if (Arg2->use_empty())
273  if (Constant *C = dyn_cast<Constant>(Arg2))
274  DeadConstants.push_back(C);
275  }
276  Declare->eraseFromParent();
277  }
278 
279  while (!DeadConstants.empty()) {
280  Constant *C = DeadConstants.back();
281  DeadConstants.pop_back();
282  if (GlobalVariable *GV = dyn_cast<GlobalVariable>(C)) {
283  if (GV->hasLocalLinkage())
284  RemoveDeadConstant(GV);
285  } else
287  }
288 
289  return true;
290 }
291 
292 bool StripDebugDeclare::runOnModule(Module &M) {
293  if (skipModule(M))
294  return false;
295  return stripDebugDeclareImpl(M);
296 }
297 
298 /// Collects compilation units referenced by functions or lexical scopes.
299 /// Accepts any DIScope and uses recursive bottom-up approach to reach either
300 /// DISubprogram or DILexicalBlockBase.
301 static void
302 collectCUsWithScope(const DIScope *Scope, std::set<DICompileUnit *> &LiveCUs,
303  SmallPtrSet<const DIScope *, 8> &VisitedScopes) {
304  if (!Scope)
305  return;
306 
307  auto InS = VisitedScopes.insert(Scope);
308  if (!InS.second)
309  return;
310 
311  if (const auto *SP = dyn_cast<DISubprogram>(Scope)) {
312  if (SP->getUnit())
313  LiveCUs.insert(SP->getUnit());
314  return;
315  }
316  if (const auto *LB = dyn_cast<DILexicalBlockBase>(Scope)) {
317  const DISubprogram *SP = LB->getSubprogram();
318  if (SP && SP->getUnit())
319  LiveCUs.insert(SP->getUnit());
320  return;
321  }
322 
323  collectCUsWithScope(Scope->getScope(), LiveCUs, VisitedScopes);
324 }
325 
326 static void
328  std::set<DICompileUnit *> &LiveCUs,
329  SmallPtrSet<const DIScope *, 8> &VisitedScopes) {
330  if (!Loc || !Loc->getInlinedAt())
331  return;
332  collectCUsWithScope(Loc->getScope(), LiveCUs, VisitedScopes);
333  collectCUsForInlinedFuncs(Loc->getInlinedAt(), LiveCUs, VisitedScopes);
334 }
335 
337  bool Changed = false;
338 
339  LLVMContext &C = M.getContext();
340 
341  // Find all debug info in F. This is actually overkill in terms of what we
342  // want to do, but we want to try and be as resilient as possible in the face
343  // of potential debug info changes by using the formal interfaces given to us
344  // as much as possible.
346  F.processModule(M);
347 
348  // For each compile unit, find the live set of global variables/functions and
349  // replace the current list of potentially dead global variables/functions
350  // with the live list.
351  SmallVector<Metadata *, 64> LiveGlobalVariables;
353 
354  std::set<DIGlobalVariableExpression *> LiveGVs;
355  for (GlobalVariable &GV : M.globals()) {
357  GV.getDebugInfo(GVEs);
358  for (auto *GVE : GVEs)
359  LiveGVs.insert(GVE);
360  }
361 
362  std::set<DICompileUnit *> LiveCUs;
363  SmallPtrSet<const DIScope *, 8> VisitedScopes;
364  // Any CU is live if is referenced from a subprogram metadata that is attached
365  // to a function defined or inlined in the module.
366  for (const Function &Fn : M.functions()) {
367  collectCUsWithScope(Fn.getSubprogram(), LiveCUs, VisitedScopes);
368  for (const_inst_iterator I = inst_begin(&Fn), E = inst_end(&Fn); I != E;
369  ++I) {
370  if (!I->getDebugLoc())
371  continue;
372  const DILocation *DILoc = I->getDebugLoc().get();
373  collectCUsForInlinedFuncs(DILoc, LiveCUs, VisitedScopes);
374  }
375  }
376 
377  bool HasDeadCUs = false;
378  for (DICompileUnit *DIC : F.compile_units()) {
379  // Create our live global variable list.
380  bool GlobalVariableChange = false;
381  for (auto *DIG : DIC->getGlobalVariables()) {
382  if (DIG->getExpression() && DIG->getExpression()->isConstant())
383  LiveGVs.insert(DIG);
384 
385  // Make sure we only visit each global variable only once.
386  if (!VisitedSet.insert(DIG).second)
387  continue;
388 
389  // If a global variable references DIG, the global variable is live.
390  if (LiveGVs.count(DIG))
391  LiveGlobalVariables.push_back(DIG);
392  else
393  GlobalVariableChange = true;
394  }
395 
396  if (!LiveGlobalVariables.empty())
397  LiveCUs.insert(DIC);
398  else if (!LiveCUs.count(DIC))
399  HasDeadCUs = true;
400 
401  // If we found dead global variables, replace the current global
402  // variable list with our new live global variable list.
403  if (GlobalVariableChange) {
404  DIC->replaceGlobalVariables(MDTuple::get(C, LiveGlobalVariables));
405  Changed = true;
406  }
407 
408  // Reset lists for the next iteration.
409  LiveGlobalVariables.clear();
410  }
411 
412  if (HasDeadCUs) {
413  // Delete the old node and replace it with a new one
414  NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.cu");
415  NMD->clearOperands();
416  if (!LiveCUs.empty()) {
417  for (DICompileUnit *CU : LiveCUs)
418  NMD->addOperand(CU);
419  }
420  Changed = true;
421  }
422 
423  return Changed;
424 }
425 
426 /// Remove any debug info for global variables/functions in the given module for
427 /// which said global variable/function no longer exists (i.e. is null).
428 ///
429 /// Debugging information is encoded in llvm IR using metadata. This is designed
430 /// such a way that debug info for symbols preserved even if symbols are
431 /// optimized away by the optimizer. This special pass removes debug info for
432 /// such symbols.
433 bool StripDeadDebugInfo::runOnModule(Module &M) {
434  if (skipModule(M))
435  return false;
436  return stripDeadDebugInfoImpl(M);
437 }
438 
440  StripDebugInfo(M);
441  StripSymbolNames(M, false);
442  return PreservedAnalyses::all();
443 }
444 
446  ModuleAnalysisManager &AM) {
447  StripSymbolNames(M, true);
448  return PreservedAnalyses::all();
449 }
450 
452  ModuleAnalysisManager &AM) {
454  return PreservedAnalyses::all();
455 }
456 
458  ModuleAnalysisManager &AM) {
460  return PreservedAnalyses::all();
461 }
i
i
Definition: README.txt:29
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:152
llvm::RecursivelyDeleteTriviallyDeadInstructions
bool RecursivelyDeleteTriviallyDeadInstructions(Value *V, const TargetLibraryInfo *TLI=nullptr, MemorySSAUpdater *MSSAU=nullptr, std::function< void(Value *)> AboutToDeleteCallback=std::function< void(Value *)>())
If the specified value is a trivially dead instruction, delete it.
Definition: Local.cpp:537
llvm::StripDebugInfo
bool StripDebugInfo(Module &M)
Strip debug info in the module if it exists.
Definition: DebugInfo.cpp:500
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
StripSymbols.h
llvm::DILocalScope::getSubprogram
DISubprogram * getSubprogram() const
Get the subprogram for this scope.
Definition: DebugInfoMetadata.cpp:965
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
llvm::NamedMDNode
A tuple of MDNodes.
Definition: Metadata.h:1588
llvm::StripDeadDebugInfoPass::run
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
Definition: StripSymbols.cpp:457
llvm::AArch64PACKey::ID
ID
Definition: AArch64BaseInfo.h:818
llvm::ModulePass
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
Definition: Pass.h:248
stripDeadDebugInfoImpl
static bool stripDeadDebugInfoImpl(Module &M)
Definition: StripSymbols.cpp:336
InstIterator.h
llvm::Function
Definition: Function.h:60
Pass.h
collectCUsForInlinedFuncs
static void collectCUsForInlinedFuncs(const DILocation *Loc, std::set< DICompileUnit * > &LiveCUs, SmallPtrSet< const DIScope *, 8 > &VisitedScopes)
Definition: StripSymbols.cpp:327
llvm::Function::eraseFromParent
void eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing module and deletes it.
Definition: Function.cpp:368
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1199
llvm::StripSymbolsPass::run
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
Definition: StripSymbols.cpp:439
llvm::GlobalVariable
Definition: GlobalVariable.h:39
Local.h
llvm::DILocation
Debug location.
Definition: DebugInfoMetadata.h:1600
Module.h
llvm::initializeStripDeadDebugInfoPass
void initializeStripDeadDebugInfoPass(PassRegistry &)
llvm::SmallPtrSet
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition: SmallPtrSet.h:450
llvm::detail::DenseSetImpl< ValueT, DenseMap< ValueT, detail::DenseSetEmpty, DenseMapInfo< ValueT >, detail::DenseSetPair< ValueT > >, DenseMapInfo< ValueT > >::insert
std::pair< iterator, bool > insert(const ValueT &V)
Definition: DenseSet.h:206
llvm::DebugInfoFinder
Utility to find all debug info in a module.
Definition: DebugInfo.h:98
llvm::createStripDebugDeclarePass
ModulePass * createStripDebugDeclarePass()
F
#define F(x, y, z)
Definition: MD5.cpp:55
OnlyUsedBy
static bool OnlyUsedBy(Value *V, Value *Usr)
OnlyUsedBy - Return true if V is only used by Usr.
Definition: StripSymbols.cpp:137
collectCUsWithScope
static void collectCUsWithScope(const DIScope *Scope, std::set< DICompileUnit * > &LiveCUs, SmallPtrSet< const DIScope *, 8 > &VisitedScopes)
Collects compilation units referenced by functions or lexical scopes.
Definition: StripSymbols.cpp:302
RemoveDeadConstant
static void RemoveDeadConstant(Constant *C)
Definition: StripSymbols.cpp:145
llvm::NamedMDNode::addOperand
void addOperand(MDNode *M)
Definition: Metadata.cpp:1222
llvm::initializeStripDebugDeclarePass
void initializeStripDebugDeclarePass(PassRegistry &)
llvm::PassRegistry::getPassRegistry
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Definition: PassRegistry.cpp:24
llvm::StringRef::startswith
bool startswith(StringRef Prefix) const
Definition: StringRef.h:260
Constants.h
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::User
Definition: User.h:44
findUsedValues
static void findUsedValues(GlobalVariable *LLVMUsed, SmallPtrSetImpl< const GlobalValue * > &UsedValues)
Find values that are marked as llvm.used.
Definition: StripSymbols.cpp:196
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
TypeFinder.h
llvm::AnalysisUsage
Represent the analysis usage information of a pass.
Definition: PassAnalysisSupport.h:47
llvm::ConstantArray
ConstantArray - Constant Array Declarations.
Definition: Constants.h:410
llvm::Value::setName
void setName(const Twine &Name)
Change the name of the value.
Definition: Value.cpp:375
SmallPtrSet.h
llvm::Value::use_empty
bool use_empty() const
Definition: Value.h:344
llvm::CallingConv::ID
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24
ValueSymbolTable.h
Operands
mir Rename Register Operands
Definition: MIRNamerPass.cpp:74
llvm::Value::user_back
User * user_back()
Definition: Value.h:407
llvm::DenseSet
Implements a dense probed hash-table based set.
Definition: DenseSet.h:268
llvm::StripNonDebugSymbolsPass::run
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
Definition: StripSymbols.cpp:445
llvm::RISCVFenceField::O
@ O
Definition: RISCVBaseInfo.h:264
llvm::GlobalValue
Definition: GlobalValue.h:44
llvm::GlobalVariable::getInitializer
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
Definition: GlobalVariable.h:135
VI
@ VI
Definition: SIInstrInfo.cpp:7967
llvm::Constant
This is an important base class in LLVM.
Definition: Constant.h:41
llvm::StringMapIterator
Definition: StringMap.h:27
llvm::Instruction::eraseFromParent
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
Definition: Instruction.cpp:81
llvm::ARM_MB::ST
@ ST
Definition: ARMBaseInfo.h:73
IPO.h
llvm::LLVMContext
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:67
llvm::numbers::e
constexpr double e
Definition: MathExtras.h:53
DebugInfo.h
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::DICompileUnit
Compile unit.
Definition: DebugInfoMetadata.h:1365
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::MDTuple::get
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition: Metadata.h:1357
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
llvm::createStripSymbolsPass
ModulePass * createStripSymbolsPass(bool OnlyDebugInfo=false)
llvm::StructType
Class to represent struct types.
Definition: DerivedTypes.h:213
llvm::TypeFinder::run
void run(const Module &M, bool onlyNamed)
Definition: TypeFinder.cpp:34
llvm::TypeFinder
TypeFinder - Walk over a module, identifying all of the types that are used by the module.
Definition: TypeFinder.h:31
llvm::createStripDeadDebugInfoPass
ModulePass * createStripDeadDebugInfoPass()
llvm::Value::getName
StringRef getName() const
Return a constant reference to the value's name.
Definition: Value.cpp:308
llvm::Value::stripPointerCasts
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
Definition: Value.cpp:685
INITIALIZE_PASS
INITIALIZE_PASS(StripSymbols, "strip", "Strip all symbols from a module", false, false) ModulePass *llvm
Definition: StripSymbols.cpp:104
llvm::StripDebugDeclarePass::run
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
Definition: StripSymbols.cpp:451
llvm::AnalysisUsage::setPreservesAll
void setPreservesAll()
Set by analyses that do not transform their input at all.
Definition: PassAnalysisSupport.h:130
llvm::DIScope
Base class for scope-like contexts.
Definition: DebugInfoMetadata.h:509
llvm::AMDGPU::SendMsg::Op
Op
Definition: SIDefines.h:351
llvm::PreservedAnalyses::all
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition: PassManager.h:158
StripSymtab
static void StripSymtab(ValueSymbolTable &ST, bool PreserveDbgInfo)
Definition: StripSymbols.cpp:168
llvm::createStripNonDebugSymbolsPass
ModulePass * createStripNonDebugSymbolsPass()
llvm::inst_end
inst_iterator inst_end(Function *F)
Definition: InstIterator.h:132
PassManager.h
stripDebugDeclareImpl
static bool stripDebugDeclareImpl(Module &M)
Definition: StripSymbols.cpp:254
llvm::initializeStripSymbolsPass
void initializeStripSymbolsPass(PassRegistry &)
llvm::SmallVectorImpl::clear
void clear()
Definition: SmallVector.h:614
Instructions.h
llvm::User::getNumOperands
unsigned getNumOperands() const
Definition: User.h:191
llvm::ValueSymbolTable
This class provides a symbol table of name/value pairs.
Definition: ValueSymbolTable.h:37
llvm::CallBase::getArgOperand
Value * getArgOperand(unsigned i) const
Definition: InstrTypes.h:1341
llvm::DISubprogram
Subprogram description.
Definition: DebugInfoMetadata.h:1846
DerivedTypes.h
llvm::SmallPtrSetImpl
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
Definition: SmallPtrSet.h:344
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:42
llvm::CallInst
This class represents a function call, abstracting a target machine's calling convention.
Definition: Instructions.h:1474
llvm::inst_begin
inst_iterator inst_begin(Function *F)
Definition: InstIterator.h:131
llvm::User::getOperand
Value * getOperand(unsigned i) const
Definition: User.h:169
llvm::InstIterator
Definition: InstIterator.h:32
llvm::NamedMDNode::clearOperands
void clearOperands()
Drop all references to this node's operands.
Definition: Metadata.cpp:1231
StripTypeNames
static void StripTypeNames(Module &M, bool PreserveDbgInfo)
Definition: StripSymbols.cpp:181
llvm::SmallPtrSetImpl::contains
bool contains(ConstPtrType Ptr) const
Definition: SmallPtrSet.h:389
CU
Definition: AArch64AsmBackend.cpp:505
InitializePasses.h
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::Value::users
iterator_range< user_iterator > users()
Definition: Value.h:421
llvm::SmallPtrSetImpl::insert
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
Definition: SmallPtrSet.h:365
llvm::SmallVectorImpl::insert
iterator insert(iterator I, T &&Elt)
Definition: SmallVector.h:809
StripSymbolNames
static bool StripSymbolNames(Module &M, bool PreserveDbgInfo)
StripSymbolNames - Strip symbol names.
Definition: StripSymbols.cpp:210
llvm::initializeStripNonDebugSymbolsPass
void initializeStripNonDebugSymbolsPass(PassRegistry &)