LLVM  15.0.0git
SymbolRewriter.cpp
Go to the documentation of this file.
1 //===- SymbolRewriter.cpp - Symbol Rewriter -------------------------------===//
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 // SymbolRewriter is a LLVM pass which can rewrite symbols transparently within
10 // existing code. It is implemented as a compiler pass and is configured via a
11 // YAML configuration file.
12 //
13 // The YAML configuration file format is as follows:
14 //
15 // RewriteMapFile := RewriteDescriptors
16 // RewriteDescriptors := RewriteDescriptor | RewriteDescriptors
17 // RewriteDescriptor := RewriteDescriptorType ':' '{' RewriteDescriptorFields '}'
18 // RewriteDescriptorFields := RewriteDescriptorField | RewriteDescriptorFields
19 // RewriteDescriptorField := FieldIdentifier ':' FieldValue ','
20 // RewriteDescriptorType := Identifier
21 // FieldIdentifier := Identifier
22 // FieldValue := Identifier
23 // Identifier := [0-9a-zA-Z]+
24 //
25 // Currently, the following descriptor types are supported:
26 //
27 // - function: (function rewriting)
28 // + Source (original name of the function)
29 // + Target (explicit transformation)
30 // + Transform (pattern transformation)
31 // + Naked (boolean, whether the function is undecorated)
32 // - global variable: (external linkage global variable rewriting)
33 // + Source (original name of externally visible variable)
34 // + Target (explicit transformation)
35 // + Transform (pattern transformation)
36 // - global alias: (global alias rewriting)
37 // + Source (original name of the aliased name)
38 // + Target (explicit transformation)
39 // + Transform (pattern transformation)
40 //
41 // Note that source and exactly one of [Target, Transform] must be provided
42 //
43 // New rewrite descriptors can be created. Addding a new rewrite descriptor
44 // involves:
45 //
46 // a) extended the rewrite descriptor kind enumeration
47 // (<anonymous>::RewriteDescriptor::RewriteDescriptorType)
48 // b) implementing the new descriptor
49 // (c.f. <anonymous>::ExplicitRewriteFunctionDescriptor)
50 // c) extending the rewrite map parser
51 // (<anonymous>::RewriteMapParser::parseEntry)
52 //
53 // Specify to rewrite the symbols using the `-rewrite-symbols` option, and
54 // specify the map file to use for the rewriting via the `-rewrite-map-file`
55 // option.
56 //
57 //===----------------------------------------------------------------------===//
58 
60 #include "llvm/ADT/SmallString.h"
61 #include "llvm/ADT/StringRef.h"
62 #include "llvm/ADT/ilist.h"
64 #include "llvm/IR/Comdat.h"
65 #include "llvm/IR/Function.h"
66 #include "llvm/IR/GlobalAlias.h"
67 #include "llvm/IR/GlobalObject.h"
68 #include "llvm/IR/GlobalVariable.h"
69 #include "llvm/IR/Module.h"
70 #include "llvm/IR/Value.h"
71 #include "llvm/InitializePasses.h"
72 #include "llvm/Pass.h"
73 #include "llvm/Support/Casting.h"
76 #include "llvm/Support/ErrorOr.h"
78 #include "llvm/Support/Regex.h"
79 #include "llvm/Support/SourceMgr.h"
81 #include <memory>
82 #include <string>
83 #include <vector>
84 
85 using namespace llvm;
86 using namespace SymbolRewriter;
87 
88 #define DEBUG_TYPE "symbol-rewriter"
89 
90 static cl::list<std::string> RewriteMapFiles("rewrite-map-file",
91  cl::desc("Symbol Rewrite Map"),
92  cl::value_desc("filename"),
93  cl::Hidden);
94 
95 static void rewriteComdat(Module &M, GlobalObject *GO,
96  const std::string &Source,
97  const std::string &Target) {
98  if (Comdat *CD = GO->getComdat()) {
99  auto &Comdats = M.getComdatSymbolTable();
100 
101  Comdat *C = M.getOrInsertComdat(Target);
102  C->setSelectionKind(CD->getSelectionKind());
103  GO->setComdat(C);
104 
105  Comdats.erase(Comdats.find(Source));
106  }
107 }
108 
109 namespace {
110 
111 template <RewriteDescriptor::Type DT, typename ValueType,
112  ValueType *(Module::*Get)(StringRef) const>
113 class ExplicitRewriteDescriptor : public RewriteDescriptor {
114 public:
115  const std::string Source;
116  const std::string Target;
117 
118  ExplicitRewriteDescriptor(StringRef S, StringRef T, const bool Naked)
119  : RewriteDescriptor(DT),
120  Source(std::string(Naked ? StringRef("\01" + S.str()) : S)),
121  Target(std::string(T)) {}
122 
123  bool performOnModule(Module &M) override;
124 
125  static bool classof(const RewriteDescriptor *RD) {
126  return RD->getType() == DT;
127  }
128 };
129 
130 } // end anonymous namespace
131 
132 template <RewriteDescriptor::Type DT, typename ValueType,
133  ValueType *(Module::*Get)(StringRef) const>
134 bool ExplicitRewriteDescriptor<DT, ValueType, Get>::performOnModule(Module &M) {
135  bool Changed = false;
136  if (ValueType *S = (M.*Get)(Source)) {
137  if (GlobalObject *GO = dyn_cast<GlobalObject>(S))
138  rewriteComdat(M, GO, Source, Target);
139 
140  if (Value *T = (M.*Get)(Target))
141  S->setValueName(T->getValueName());
142  else
143  S->setName(Target);
144 
145  Changed = true;
146  }
147  return Changed;
148 }
149 
150 namespace {
151 
152 template <RewriteDescriptor::Type DT, typename ValueType,
153  ValueType *(Module::*Get)(StringRef) const,
155  (Module::*Iterator)()>
156 class PatternRewriteDescriptor : public RewriteDescriptor {
157 public:
158  const std::string Pattern;
159  const std::string Transform;
160 
161  PatternRewriteDescriptor(StringRef P, StringRef T)
163  Transform(std::string(T)) {}
164 
165  bool performOnModule(Module &M) override;
166 
167  static bool classof(const RewriteDescriptor *RD) {
168  return RD->getType() == DT;
169  }
170 };
171 
172 } // end anonymous namespace
173 
174 template <RewriteDescriptor::Type DT, typename ValueType,
175  ValueType *(Module::*Get)(StringRef) const,
177  (Module::*Iterator)()>
178 bool PatternRewriteDescriptor<DT, ValueType, Get, Iterator>::
179 performOnModule(Module &M) {
180  bool Changed = false;
181  for (auto &C : (M.*Iterator)()) {
182  std::string Error;
183 
184  std::string Name = Regex(Pattern).sub(Transform, C.getName(), &Error);
185  if (!Error.empty())
186  report_fatal_error(Twine("unable to transforn ") + C.getName() + " in " +
187  M.getModuleIdentifier() + ": " + Error);
188 
189  if (C.getName() == Name)
190  continue;
191 
192  if (GlobalObject *GO = dyn_cast<GlobalObject>(&C))
193  rewriteComdat(M, GO, std::string(C.getName()), Name);
194 
195  if (Value *V = (M.*Get)(Name))
196  C.setValueName(V->getValueName());
197  else
198  C.setName(Name);
199 
200  Changed = true;
201  }
202  return Changed;
203 }
204 
205 namespace {
206 
207 /// Represents a rewrite for an explicitly named (function) symbol. Both the
208 /// source function name and target function name of the transformation are
209 /// explicitly spelt out.
210 using ExplicitRewriteFunctionDescriptor =
211  ExplicitRewriteDescriptor<RewriteDescriptor::Type::Function, Function,
213 
214 /// Represents a rewrite for an explicitly named (global variable) symbol. Both
215 /// the source variable name and target variable name are spelt out. This
216 /// applies only to module level variables.
217 using ExplicitRewriteGlobalVariableDescriptor =
218  ExplicitRewriteDescriptor<RewriteDescriptor::Type::GlobalVariable,
220 
221 /// Represents a rewrite for an explicitly named global alias. Both the source
222 /// and target name are explicitly spelt out.
223 using ExplicitRewriteNamedAliasDescriptor =
224  ExplicitRewriteDescriptor<RewriteDescriptor::Type::NamedAlias, GlobalAlias,
226 
227 /// Represents a rewrite for a regular expression based pattern for functions.
228 /// A pattern for the function name is provided and a transformation for that
229 /// pattern to determine the target function name create the rewrite rule.
230 using PatternRewriteFunctionDescriptor =
231  PatternRewriteDescriptor<RewriteDescriptor::Type::Function, Function,
233 
234 /// Represents a rewrite for a global variable based upon a matching pattern.
235 /// Each global variable matching the provided pattern will be transformed as
236 /// described in the transformation pattern for the target. Applies only to
237 /// module level variables.
238 using PatternRewriteGlobalVariableDescriptor =
239  PatternRewriteDescriptor<RewriteDescriptor::Type::GlobalVariable,
241  &Module::globals>;
242 
243 /// PatternRewriteNamedAliasDescriptor - represents a rewrite for global
244 /// aliases which match a given pattern. The provided transformation will be
245 /// applied to each of the matching names.
246 using PatternRewriteNamedAliasDescriptor =
247  PatternRewriteDescriptor<RewriteDescriptor::Type::NamedAlias, GlobalAlias,
249 
250 } // end anonymous namespace
251 
252 bool RewriteMapParser::parse(const std::string &MapFile,
255  MemoryBuffer::getFile(MapFile);
256 
257  if (!Mapping)
258  report_fatal_error(Twine("unable to read rewrite map '") + MapFile +
259  "': " + Mapping.getError().message());
260 
261  if (!parse(*Mapping, DL))
262  report_fatal_error(Twine("unable to parse rewrite map '") + MapFile + "'");
263 
264  return true;
265 }
266 
267 bool RewriteMapParser::parse(std::unique_ptr<MemoryBuffer> &MapFile,
269  SourceMgr SM;
270  yaml::Stream YS(MapFile->getBuffer(), SM);
271 
272  for (auto &Document : YS) {
273  yaml::MappingNode *DescriptorList;
274 
275  // ignore empty documents
276  if (isa<yaml::NullNode>(Document.getRoot()))
277  continue;
278 
279  DescriptorList = dyn_cast<yaml::MappingNode>(Document.getRoot());
280  if (!DescriptorList) {
281  YS.printError(Document.getRoot(), "DescriptorList node must be a map");
282  return false;
283  }
284 
285  for (auto &Descriptor : *DescriptorList)
286  if (!parseEntry(YS, Descriptor, DL))
287  return false;
288  }
289 
290  return true;
291 }
292 
293 bool RewriteMapParser::parseEntry(yaml::Stream &YS, yaml::KeyValueNode &Entry,
297  SmallString<32> KeyStorage;
298  StringRef RewriteType;
299 
300  Key = dyn_cast<yaml::ScalarNode>(Entry.getKey());
301  if (!Key) {
302  YS.printError(Entry.getKey(), "rewrite type must be a scalar");
303  return false;
304  }
305 
306  Value = dyn_cast<yaml::MappingNode>(Entry.getValue());
307  if (!Value) {
308  YS.printError(Entry.getValue(), "rewrite descriptor must be a map");
309  return false;
310  }
311 
312  RewriteType = Key->getValue(KeyStorage);
313  if (RewriteType.equals("function"))
314  return parseRewriteFunctionDescriptor(YS, Key, Value, DL);
315  else if (RewriteType.equals("global variable"))
316  return parseRewriteGlobalVariableDescriptor(YS, Key, Value, DL);
317  else if (RewriteType.equals("global alias"))
318  return parseRewriteGlobalAliasDescriptor(YS, Key, Value, DL);
319 
320  YS.printError(Entry.getKey(), "unknown rewrite type");
321  return false;
322 }
323 
324 bool RewriteMapParser::
325 parseRewriteFunctionDescriptor(yaml::Stream &YS, yaml::ScalarNode *K,
326  yaml::MappingNode *Descriptor,
328  bool Naked = false;
329  std::string Source;
330  std::string Target;
331  std::string Transform;
332 
333  for (auto &Field : *Descriptor) {
336  SmallString<32> KeyStorage;
337  SmallString<32> ValueStorage;
338  StringRef KeyValue;
339 
340  Key = dyn_cast<yaml::ScalarNode>(Field.getKey());
341  if (!Key) {
342  YS.printError(Field.getKey(), "descriptor key must be a scalar");
343  return false;
344  }
345 
346  Value = dyn_cast<yaml::ScalarNode>(Field.getValue());
347  if (!Value) {
348  YS.printError(Field.getValue(), "descriptor value must be a scalar");
349  return false;
350  }
351 
352  KeyValue = Key->getValue(KeyStorage);
353  if (KeyValue.equals("source")) {
354  std::string Error;
355 
356  Source = std::string(Value->getValue(ValueStorage));
357  if (!Regex(Source).isValid(Error)) {
358  YS.printError(Field.getKey(), "invalid regex: " + Error);
359  return false;
360  }
361  } else if (KeyValue.equals("target")) {
362  Target = std::string(Value->getValue(ValueStorage));
363  } else if (KeyValue.equals("transform")) {
364  Transform = std::string(Value->getValue(ValueStorage));
365  } else if (KeyValue.equals("naked")) {
366  std::string Undecorated;
367 
368  Undecorated = std::string(Value->getValue(ValueStorage));
369  Naked = StringRef(Undecorated).lower() == "true" || Undecorated == "1";
370  } else {
371  YS.printError(Field.getKey(), "unknown key for function");
372  return false;
373  }
374  }
375 
376  if (Transform.empty() == Target.empty()) {
377  YS.printError(Descriptor,
378  "exactly one of transform or target must be specified");
379  return false;
380  }
381 
382  // TODO see if there is a more elegant solution to selecting the rewrite
383  // descriptor type
384  if (!Target.empty())
385  DL->push_back(std::make_unique<ExplicitRewriteFunctionDescriptor>(
386  Source, Target, Naked));
387  else
388  DL->push_back(
389  std::make_unique<PatternRewriteFunctionDescriptor>(Source, Transform));
390 
391  return true;
392 }
393 
394 bool RewriteMapParser::
395 parseRewriteGlobalVariableDescriptor(yaml::Stream &YS, yaml::ScalarNode *K,
396  yaml::MappingNode *Descriptor,
398  std::string Source;
399  std::string Target;
400  std::string Transform;
401 
402  for (auto &Field : *Descriptor) {
405  SmallString<32> KeyStorage;
406  SmallString<32> ValueStorage;
407  StringRef KeyValue;
408 
409  Key = dyn_cast<yaml::ScalarNode>(Field.getKey());
410  if (!Key) {
411  YS.printError(Field.getKey(), "descriptor Key must be a scalar");
412  return false;
413  }
414 
415  Value = dyn_cast<yaml::ScalarNode>(Field.getValue());
416  if (!Value) {
417  YS.printError(Field.getValue(), "descriptor value must be a scalar");
418  return false;
419  }
420 
421  KeyValue = Key->getValue(KeyStorage);
422  if (KeyValue.equals("source")) {
423  std::string Error;
424 
425  Source = std::string(Value->getValue(ValueStorage));
426  if (!Regex(Source).isValid(Error)) {
427  YS.printError(Field.getKey(), "invalid regex: " + Error);
428  return false;
429  }
430  } else if (KeyValue.equals("target")) {
431  Target = std::string(Value->getValue(ValueStorage));
432  } else if (KeyValue.equals("transform")) {
433  Transform = std::string(Value->getValue(ValueStorage));
434  } else {
435  YS.printError(Field.getKey(), "unknown Key for Global Variable");
436  return false;
437  }
438  }
439 
440  if (Transform.empty() == Target.empty()) {
441  YS.printError(Descriptor,
442  "exactly one of transform or target must be specified");
443  return false;
444  }
445 
446  if (!Target.empty())
447  DL->push_back(std::make_unique<ExplicitRewriteGlobalVariableDescriptor>(
448  Source, Target,
449  /*Naked*/ false));
450  else
451  DL->push_back(std::make_unique<PatternRewriteGlobalVariableDescriptor>(
452  Source, Transform));
453 
454  return true;
455 }
456 
457 bool RewriteMapParser::
458 parseRewriteGlobalAliasDescriptor(yaml::Stream &YS, yaml::ScalarNode *K,
459  yaml::MappingNode *Descriptor,
461  std::string Source;
462  std::string Target;
463  std::string Transform;
464 
465  for (auto &Field : *Descriptor) {
468  SmallString<32> KeyStorage;
469  SmallString<32> ValueStorage;
470  StringRef KeyValue;
471 
472  Key = dyn_cast<yaml::ScalarNode>(Field.getKey());
473  if (!Key) {
474  YS.printError(Field.getKey(), "descriptor key must be a scalar");
475  return false;
476  }
477 
478  Value = dyn_cast<yaml::ScalarNode>(Field.getValue());
479  if (!Value) {
480  YS.printError(Field.getValue(), "descriptor value must be a scalar");
481  return false;
482  }
483 
484  KeyValue = Key->getValue(KeyStorage);
485  if (KeyValue.equals("source")) {
486  std::string Error;
487 
488  Source = std::string(Value->getValue(ValueStorage));
489  if (!Regex(Source).isValid(Error)) {
490  YS.printError(Field.getKey(), "invalid regex: " + Error);
491  return false;
492  }
493  } else if (KeyValue.equals("target")) {
494  Target = std::string(Value->getValue(ValueStorage));
495  } else if (KeyValue.equals("transform")) {
496  Transform = std::string(Value->getValue(ValueStorage));
497  } else {
498  YS.printError(Field.getKey(), "unknown key for Global Alias");
499  return false;
500  }
501  }
502 
503  if (Transform.empty() == Target.empty()) {
504  YS.printError(Descriptor,
505  "exactly one of transform or target must be specified");
506  return false;
507  }
508 
509  if (!Target.empty())
510  DL->push_back(std::make_unique<ExplicitRewriteNamedAliasDescriptor>(
511  Source, Target,
512  /*Naked*/ false));
513  else
514  DL->push_back(std::make_unique<PatternRewriteNamedAliasDescriptor>(
515  Source, Transform));
516 
517  return true;
518 }
519 
520 namespace {
521 
522 class RewriteSymbolsLegacyPass : public ModulePass {
523 public:
524  static char ID; // Pass identification, replacement for typeid
525 
526  RewriteSymbolsLegacyPass();
527  RewriteSymbolsLegacyPass(SymbolRewriter::RewriteDescriptorList &DL);
528 
529  bool runOnModule(Module &M) override;
530 
531 private:
532  RewriteSymbolPass Impl;
533 };
534 
535 } // end anonymous namespace
536 
538 
539 RewriteSymbolsLegacyPass::RewriteSymbolsLegacyPass() : ModulePass(ID) {
541 }
542 
543 RewriteSymbolsLegacyPass::RewriteSymbolsLegacyPass(
545  : ModulePass(ID), Impl(DL) {}
546 
547 bool RewriteSymbolsLegacyPass::runOnModule(Module &M) {
548  return Impl.runImpl(M);
549 }
550 
552  if (!runImpl(M))
553  return PreservedAnalyses::all();
554 
555  return PreservedAnalyses::none();
556 }
557 
559  bool Changed;
560 
561  Changed = false;
562  for (auto &Descriptor : Descriptors)
563  Changed |= Descriptor->performOnModule(M);
564 
565  return Changed;
566 }
567 
568 void RewriteSymbolPass::loadAndParseMapFiles() {
569  const std::vector<std::string> MapFiles(RewriteMapFiles);
571 
572  for (const auto &MapFile : MapFiles)
573  Parser.parse(MapFile, &Descriptors);
574 }
575 
576 INITIALIZE_PASS(RewriteSymbolsLegacyPass, "rewrite-symbols", "Rewrite Symbols",
577  false, false)
578 
580  return new RewriteSymbolsLegacyPass();
581 }
582 
583 ModulePass *
585  return new RewriteSymbolsLegacyPass(DL);
586 }
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:152
MemoryBuffer.h
SymbolRewriter.h
llvm::GlobalObject::setComdat
void setComdat(Comdat *C)
Definition: Globals.cpp:194
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
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
Comdat.h
llvm::ModulePass
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
Definition: Pass.h:248
T
llvm::Function
Definition: Function.h:60
StringRef.h
P
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
Definition: README-SSE.txt:411
Pass.h
YAMLParser.h
llvm::Target
Target - Wrapper for Target specific information.
Definition: TargetRegistry.h:145
ilist.h
llvm::RewriteSymbolPass
Definition: SymbolRewriter.h:120
llvm::SymbolRewriter::RewriteDescriptorList
std::list< std::unique_ptr< RewriteDescriptor > > RewriteDescriptorList
Definition: SymbolRewriter.h:92
ErrorHandling.h
llvm::GlobalVariable
Definition: GlobalVariable.h:39
llvm::GlobalAlias
Definition: GlobalAlias.h:28
RewriteMapFiles
static cl::list< std::string > RewriteMapFiles("rewrite-map-file", cl::desc("Symbol Rewrite Map"), cl::value_desc("filename"), cl::Hidden)
llvm::cl::Hidden
@ Hidden
Definition: CommandLine.h:139
llvm::PreservedAnalyses::none
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
Definition: PassManager.h:155
llvm::RewriteSymbolPass::run
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
Definition: SymbolRewriter.cpp:551
Module.h
llvm::yaml::ScalarNode
A scalar node is an opaque datum that can be presented as a series of zero or more Unicode scalar val...
Definition: YAMLParser.h:211
llvm::RewriteSymbolPass::runImpl
bool runImpl(Module &M)
Definition: SymbolRewriter.cpp:558
llvm::yaml::MappingNode
Represents a YAML map created from either a block map for a flow map.
Definition: YAMLParser.h:413
GlobalObject.h
llvm::Module::getFunction
Function * getFunction(StringRef Name) const
Look up the specified function in the module symbol table.
Definition: Module.cpp:175
llvm::SymbolRewriter::RewriteDescriptor::Type::Function
@ Function
invalid
llvm::createRewriteSymbolsPass
ModulePass * createRewriteSymbolsPass()
CommandLine.h
llvm::MachineBasicBlock::push_back
void push_back(MachineInstr *MI)
Definition: MachineBasicBlock.h:875
llvm::MemoryBuffer::getFile
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFile(const Twine &Filename, bool IsText=false, bool RequiresNullTerminator=true, bool IsVolatile=false)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful,...
Definition: MemoryBuffer.cpp:239
llvm::PassRegistry::getPassRegistry
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Definition: PassRegistry.cpp:31
llvm::Module::globals
iterator_range< global_iterator > globals()
Definition: Module.h:614
SmallString.h
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::SymbolRewriter::RewriteDescriptor::getType
Type getType() const
Definition: SymbolRewriter.h:81
llvm::GlobalObject
Definition: GlobalObject.h:27
runImpl
static bool runImpl(const TargetLibraryInfo &TLI, Function &F)
Definition: ReplaceWithVeclib.cpp:176
llvm::AMDGPU::PALMD::Key
Key
PAL metadata keys.
Definition: AMDGPUMetadata.h:486
rewriteComdat
static void rewriteComdat(Module &M, GlobalObject *GO, const std::string &Source, const std::string &Target)
Definition: SymbolRewriter.cpp:95
llvm::SymbolRewriter::RewriteDescriptor::Type
Type
Definition: SymbolRewriter.h:70
llvm::Module::getNamedAlias
GlobalAlias * getNamedAlias(StringRef Name) const
Return the global alias in the module with the specified name, of arbitrary type.
Definition: Module.cpp:240
llvm::ErrorOr::getError
std::error_code getError() const
Definition: ErrorOr.h:153
llvm::GlobalObject::getComdat
const Comdat * getComdat() const
Definition: GlobalObject.h:122
llvm::SymbolRewriter::RewriteMapParser
Definition: SymbolRewriter.h:94
llvm::SymbolRewriter::RewriteDescriptor::Type::GlobalVariable
@ GlobalVariable
function - descriptor rewrites a function
llvm::yaml::Stream::printError
void printError(Node *N, const Twine &Msg, SourceMgr::DiagKind Kind=SourceMgr::DK_Error)
Definition: YAMLParser.cpp:1910
llvm::report_fatal_error
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:143
llvm::initializeRewriteSymbolsLegacyPassPass
void initializeRewriteSymbolsLegacyPassPass(PassRegistry &)
llvm::Comdat
Definition: Comdat.h:33
llvm::CallingConv::ID
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24
SourceMgr.h
llvm::StringRef::equals
LLVM_NODISCARD bool equals(StringRef RHS) const
equals - Check for string equality, this is more efficient than compare() when the relative ordering ...
Definition: StringRef.h:187
llvm::SmallString< 32 >
llvm::Module::aliases
iterator_range< alias_iterator > aliases()
Definition: Module.h:654
ErrorOr.h
llvm::codeview::FrameProcedureOptions::Naked
@ Naked
llvm::StringRef::lower
LLVM_NODISCARD std::string lower() const
Definition: StringRef.cpp:112
llvm::Module::functions
iterator_range< iterator > functions()
Definition: Module.h:636
Regex.h
llvm::Regex::sub
std::string sub(StringRef Repl, StringRef String, std::string *Error=nullptr) const
sub - Return the result of replacing the first match of the regex in String with the Repl string.
Definition: Regex.cpp:136
iterator_range.h
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
INITIALIZE_PASS
INITIALIZE_PASS(RewriteSymbolsLegacyPass, "rewrite-symbols", "Rewrite Symbols", false, false) ModulePass *llvm
Definition: SymbolRewriter.cpp:576
llvm::Sched::Source
@ Source
Definition: TargetLowering.h:99
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::SourceMgr
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling.
Definition: SourceMgr.h:31
llvm::yaml::KeyValueNode
A key and value pair.
Definition: YAMLParser.h:284
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition: AArch64SLSHardening.cpp:76
llvm::yaml::Stream
This class represents a YAML stream potentially containing multiple documents.
Definition: YAMLParser.h:85
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
Module
Machine Check Debug Module
Definition: MachineCheckDebugify.cpp:122
llvm::ValueType
PointerUnion< const Value *, const PseudoSourceValue * > ValueType
Definition: ScheduleDAGInstrs.h:106
llvm::Module::getGlobalVariable
GlobalVariable * getGlobalVariable(StringRef Name) const
Look up the specified global variable in the module symbol table.
Definition: Module.h:414
llvm::PointerUnion< const Value *, const PseudoSourceValue * >
llvm::SymbolRewriter::RewriteDescriptor
The basic entity representing a rewrite operation.
Definition: SymbolRewriter.h:68
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:83
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:50
std
Definition: BitVector.h:851
llvm::PreservedAnalyses::all
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition: PassManager.h:158
llvm::SymbolRewriter::RewriteDescriptor::Type::NamedAlias
@ NamedAlias
global variable - descriptor rewrites a global variable
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:155
GlobalVariable.h
Casting.h
Function.h
llvm::TargetStackID::Value
Value
Definition: TargetFrameLowering.h:27
llvm::cl::value_desc
Definition: CommandLine.h:414
GlobalAlias.h
isValid
static bool isValid(const char C)
Returns true if C is a valid mangled character: <0-9a-zA-Z_>.
Definition: RustDemangle.cpp:187
llvm::Pattern
Definition: FileCheckImpl.h:614
llvm::ErrorOr
Represents either an error or a value T.
Definition: ErrorOr.h:56
llvm::iterator_range
A range adaptor for a pair of iterators.
Definition: iterator_range.h:30
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:42
llvm::OptimizedStructLayoutField
A field in a structure.
Definition: OptimizedStructLayout.h:45
llvm::cl::desc
Definition: CommandLine.h:405
llvm::Regex
Definition: Regex.h:28
Value.h
InitializePasses.h
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::SymbolRewriter::RewriteMapParser::parse
bool parse(const std::string &MapFile, RewriteDescriptorList *Descriptors)
Definition: SymbolRewriter.cpp:252
SpecialSubKind::string
@ string
llvm::Intrinsic::ID
unsigned ID
Definition: TargetTransformInfo.h:38
llvm::cl::list
Definition: CommandLine.h:1601