LLVM 24.0.0git
IRNormalizer.cpp
Go to the documentation of this file.
1//===--------------- IRNormalizer.cpp - IR Normalizer ---------------===//
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/// \file
9/// This file implements the IRNormalizer class which aims to transform LLVM
10/// Modules into a normal form by reordering and renaming instructions while
11/// preserving the same semantics. The normalizer makes it easier to spot
12/// semantic differences while diffing two modules which have undergone
13/// different passes.
14///
15//===----------------------------------------------------------------------===//
16
18#include "llvm/ADT/SetVector.h"
22#include "llvm/IR/BasicBlock.h"
23#include "llvm/IR/Function.h"
24#include "llvm/IR/IRBuilder.h"
26#include "llvm/Pass.h"
27#include <stack>
28
29#define DEBUG_TYPE "normalize"
30
31using namespace llvm;
32
33// Frozen mixer; basic-block names derived from these hashes appear in
34// the normalized IR text and must be deterministic across processes
35// for the normalizer's "compare normalized IR" workflow to work.
36static constexpr uint64_t hash_16_bytes(uint64_t low, uint64_t high) {
37 const uint64_t kMul = 0x9ddfea08eb382d69ULL;
38 uint64_t a = (low ^ high) * kMul;
39 a ^= (a >> 47);
40 uint64_t b = (high ^ a) * kMul;
41 b ^= (b >> 47);
42 b *= kMul;
43 return b;
44}
45
46namespace {
47/// IRNormalizer aims to transform LLVM IR into normal form.
48class IRNormalizer {
49public:
51
52 IRNormalizer(IRNormalizerOptions Options) : Options(Options) {}
53
54private:
55 const IRNormalizerOptions Options;
56
57 // Random constant for hashing, so the state isn't zero.
58 const uint64_t MagicHashConstant = 0x6acaa36bef8325c5ULL;
59 DenseSet<const Instruction *> NamedInstructions;
60
61 SmallVector<Instruction *, 16> Outputs;
62
63 /// \name Naming.
64 /// @{
65 void nameFunctionArguments(Function &F) const;
66 void nameBasicBlocks(Function &F) const;
67 void nameInstruction(Instruction *I);
68 void nameAsInitialInstruction(Instruction *I) const;
69 void nameAsRegularInstruction(Instruction *I);
70 void foldInstructionName(Instruction *I) const;
71 /// @}
72
73 /// \name Reordering.
74 /// @{
75 void reorderInstructions(Function &F) const;
76 void reorderDefinition(Instruction *Definition,
77 std::stack<Instruction *> &TopologicalSort,
78 SmallPtrSet<const Instruction *, 32> &Visited) const;
79 void reorderInstructionOperandsByNames(Instruction *I) const;
80 void reorderPHIIncomingValues(PHINode *Phi) const;
81 /// @}
82
83 /// \name Utility methods.
84 /// @{
85 template <typename T>
86 void sortCommutativeOperands(Instruction *I, T &Operands) const;
87 SmallVector<Instruction *, 16> collectOutputInstructions(Function &F) const;
88 bool isOutput(const Instruction *I) const;
89 bool isInitialInstruction(const Instruction *I) const;
90 bool hasOnlyImmediateOperands(const Instruction *I) const;
91 SetVector<int>
92 getOutputFootprint(Instruction *I,
93 SmallPtrSet<const Instruction *, 32> &Visited) const;
94 /// @}
95};
96} // namespace
97
98/// Entry method to the IRNormalizer.
99///
100/// \param F Function to normalize.
101bool IRNormalizer::runOnFunction(Function &F) {
102 nameFunctionArguments(F);
103 nameBasicBlocks(F);
104
105 Outputs = collectOutputInstructions(F);
106
107 if (!Options.PreserveOrder)
108 reorderInstructions(F);
109
110 // TODO: Reorder basic blocks via a topological sort.
111
112 for (auto &I : Outputs)
113 nameInstruction(I);
114
115 for (auto &I : instructions(F)) {
116 if (!Options.PreserveOrder) {
117 if (Options.ReorderOperands)
118 reorderInstructionOperandsByNames(&I);
119
120 if (auto *Phi = dyn_cast<PHINode>(&I))
121 reorderPHIIncomingValues(Phi);
122 }
123 foldInstructionName(&I);
124 }
125
126 return true;
127}
128
129/// Numbers arguments.
130///
131/// \param F Function whose arguments will be renamed.
132void IRNormalizer::nameFunctionArguments(Function &F) const {
133 int ArgumentCounter = 0;
134 for (auto &A : F.args()) {
135 if (Options.RenameAll || A.getName().empty()) {
136 A.setName("a" + Twine(ArgumentCounter));
137 ArgumentCounter += 1;
138 }
139 }
140}
141
142/// Names basic blocks using a generated hash for each basic block in
143/// a function considering the opcode and the order of output instructions.
144///
145/// \param F Function containing basic blocks to rename.
146void IRNormalizer::nameBasicBlocks(Function &F) const {
147 for (auto &B : F) {
148 // Initialize to a magic constant, so the state isn't zero.
149 uint64_t Hash = MagicHashConstant;
150
151 // Hash considering output instruction opcodes.
152 for (auto &I : B)
153 if (isOutput(&I))
154 Hash = hash_16_bytes(Hash, I.getOpcode());
155
156 if (Options.RenameAll || B.getName().empty()) {
157 // Name basic block. Substring hash to make diffs more readable.
158 B.setName("bb" + std::to_string(Hash).substr(0, 5));
159 }
160 }
161}
162
163/// Names instructions graphically (recursive) in accordance with the
164/// def-use tree, starting from the initial instructions (defs), finishing at
165/// the output (top-most user) instructions (depth-first).
166///
167/// \param I Instruction to be renamed.
168void IRNormalizer::nameInstruction(Instruction *I) {
169 // Ensure instructions are not renamed. This is done
170 // to prevent situation where instructions are used
171 // before their definition (in phi nodes)
172 if (NamedInstructions.contains(I))
173 return;
174 NamedInstructions.insert(I);
175 if (isInitialInstruction(I)) {
176 nameAsInitialInstruction(I);
177 } else {
178 // This must be a regular instruction.
179 nameAsRegularInstruction(I);
180 }
181}
182
183template <typename T>
184void IRNormalizer::sortCommutativeOperands(Instruction *I, T &Operands) const {
185 if (!(I->isCommutative() && Operands.size() >= 2))
186 return;
187 auto CommutativeEnd = Operands.begin();
188 std::advance(CommutativeEnd, 2);
189 llvm::sort(Operands.begin(), CommutativeEnd);
190}
191
192/// Names instruction following the scheme:
193/// vl00000Callee(Operands)
194///
195/// Where 00000 is a hash calculated considering instruction's opcode and output
196/// footprint. Callee's name is only included when instruction's type is
197/// CallInst. In cases where instruction is commutative, operands list is also
198/// sorted.
199///
200/// Renames instruction only when RenameAll flag is raised or instruction is
201/// unnamed.
202///
203/// \see getOutputFootprint()
204/// \param I Instruction to be renamed.
205void IRNormalizer::nameAsInitialInstruction(Instruction *I) const {
206 if (I->getType()->isVoidTy())
207 return;
208 if (!(I->getName().empty() || Options.RenameAll))
209 return;
210 LLVM_DEBUG(dbgs() << "Naming initial instruction: " << *I << "\n");
211
212 // Instruction operands for further sorting.
214
215 // Collect operands.
216 for (auto &Op : I->operands()) {
217 if (!isa<Function>(Op)) {
218 std::string TextRepresentation;
219 raw_string_ostream Stream(TextRepresentation);
220 Op->printAsOperand(Stream, false);
221 Operands.push_back(StringRef(Stream.str()));
222 }
223 }
224
225 sortCommutativeOperands(I, Operands);
226
227 // Initialize to a magic constant, so the state isn't zero.
228 uint64_t Hash = MagicHashConstant;
229
230 // Consider instruction's opcode in the hash.
231 Hash = hash_16_bytes(Hash, I->getOpcode());
232
233 SmallPtrSet<const Instruction *, 32> Visited;
234 // Get output footprint for I.
235 SetVector<int> OutputFootprint = getOutputFootprint(I, Visited);
236
237 // Consider output footprint in the hash.
238 for (const int &Output : OutputFootprint)
239 Hash = hash_16_bytes(Hash, Output);
240
241 // Base instruction name.
242 SmallString<256> Name;
243 Name.append("vl" + std::to_string(Hash).substr(0, 5));
244
245 // In case of CallInst, consider callee in the instruction name.
246 if (const auto *CI = dyn_cast<CallInst>(I)) {
247 Function *F = CI->getCalledFunction();
248
249 if (F != nullptr)
250 Name.append(F->getName());
251 }
252
253 Name.append("(");
254 for (size_t i = 0; i < Operands.size(); ++i) {
255 Name.append(Operands[i]);
256
257 if (i < Operands.size() - 1)
258 Name.append(", ");
259 }
260 Name.append(")");
261
262 I->setName(Name);
263}
264
265/// Names instruction following the scheme:
266/// op00000Callee(Operands)
267///
268/// Where 00000 is a hash calculated considering instruction's opcode, its
269/// operands' opcodes and order. Callee's name is only included when
270/// instruction's type is CallInst. In cases where instruction is commutative,
271/// operand list is also sorted.
272///
273/// Names instructions recursively in accordance with the def-use tree,
274/// starting from the initial instructions (defs), finishing at
275/// the output (top-most user) instructions (depth-first).
276///
277/// Renames instruction only when RenameAll flag is raised or instruction is
278/// unnamed.
279///
280/// \see getOutputFootprint()
281/// \param I Instruction to be renamed.
282void IRNormalizer::nameAsRegularInstruction(Instruction *I) {
283 LLVM_DEBUG(dbgs() << "Naming regular instruction: " << *I << "\n");
284
285 // Instruction operands for further sorting.
287
288 // The name of a regular instruction depends
289 // on the names of its operands. Hence, all
290 // operands must be named first in the use-def
291 // walk.
292
293 // Collect operands.
294 for (auto &Op : I->operands()) {
295 if (auto *I = dyn_cast<Instruction>(Op)) {
296 // Walk down the use-def chain.
297 nameInstruction(I);
298 Operands.push_back(I->getName());
299 } else if (!isa<Function>(Op)) {
300 // This must be an immediate value.
301 std::string TextRepresentation;
302 raw_string_ostream Stream(TextRepresentation);
303 Op->printAsOperand(Stream, false);
304 Operands.push_back(StringRef(Stream.str()));
305 }
306 }
307
308 sortCommutativeOperands(I, Operands);
309
310 // Initialize to a magic constant, so the state isn't zero.
311 uint64_t Hash = MagicHashConstant;
312
313 // Consider instruction opcode in the hash.
314 Hash = hash_16_bytes(Hash, I->getOpcode());
315
316 // Operand opcodes for further sorting (commutative).
317 SmallVector<int, 4> OperandsOpcodes;
318
319 // Collect operand opcodes for hashing.
320 for (auto &Op : I->operands())
321 if (auto *I = dyn_cast<Instruction>(Op))
322 OperandsOpcodes.push_back(I->getOpcode());
323
324 sortCommutativeOperands(I, OperandsOpcodes);
325
326 // Consider operand opcodes in the hash.
327 for (const int Code : OperandsOpcodes)
328 Hash = hash_16_bytes(Hash, Code);
329
330 // Base instruction name.
331 SmallString<512> Name;
332 Name.append("op" + std::to_string(Hash).substr(0, 5));
333
334 // In case of CallInst, consider callee in the instruction name.
335 if (const auto *CI = dyn_cast<CallInst>(I))
336 if (const Function *F = CI->getCalledFunction())
337 Name.append(F->getName());
338
339 Name.append("(");
340 for (size_t i = 0; i < Operands.size(); ++i) {
341 Name.append(Operands[i]);
342
343 if (i < Operands.size() - 1)
344 Name.append(", ");
345 }
346 Name.append(")");
347
348 if ((I->getName().empty() || Options.RenameAll) && !I->getType()->isVoidTy())
349 I->setName(Name);
350}
351
352/// Shortens instruction's name. This method removes called function name from
353/// the instruction name and substitutes the call chain with a corresponding
354/// list of operands.
355///
356/// Examples:
357/// op00000Callee(op00001Callee(...), vl00000Callee(1, 2), ...) ->
358/// op00000(op00001, vl00000, ...) vl00000Callee(1, 2) -> vl00000(1, 2)
359///
360/// This method omits output instructions and pre-output (instructions directly
361/// used by an output instruction) instructions (by default). By default it also
362/// does not affect user named instructions.
363///
364/// \param I Instruction whose name will be folded.
365void IRNormalizer::foldInstructionName(Instruction *I) const {
366 // If this flag is raised, fold all regular
367 // instructions (including pre-outputs).
368 if (!Options.FoldPreOutputs) {
369 // Don't fold if one of the users is an output instruction.
370 for (auto *U : I->users())
371 if (auto *IU = dyn_cast<Instruction>(U))
372 if (isOutput(IU))
373 return;
374 }
375
376 // Don't fold if it is an output instruction or has no op prefix.
377 if (isOutput(I) || !I->getName().starts_with("op"))
378 return;
379
380 // Instruction operands.
382
383 for (auto &Op : I->operands()) {
384 if (const auto *I = dyn_cast<Instruction>(Op)) {
385 bool HasNormalName =
386 I->getName().starts_with("op") || I->getName().starts_with("vl");
387
388 Operands.push_back(HasNormalName ? I->getName().substr(0, 7)
389 : I->getName());
390 }
391 }
392
393 sortCommutativeOperands(I, Operands);
394
395 SmallString<256> Name;
396 Name.append(I->getName().substr(0, 7));
397
398 Name.append("(");
399 for (size_t i = 0; i < Operands.size(); ++i) {
400 Name.append(Operands[i]);
401
402 if (i < Operands.size() - 1)
403 Name.append(", ");
404 }
405 Name.append(")");
406
407 I->setName(Name);
408}
409
410/// Reorders the instructions in each basic block. Allocas, instructions that
411/// access memory or have side effects, and terminators are visited from first
412/// to last, so they keep their relative order. Each one first pulls in the
413/// operands it needs, so other instructions move down to just before their
414/// first user in the block, or to the end of the block if they have none.
415///
416/// \see reorderDefinition()
417void IRNormalizer::reorderInstructions(Function &F) const {
418 for (auto &BB : F) {
419 LLVM_DEBUG(dbgs() << "Reordering instructions in basic block: "
420 << BB.getName() << "\n");
421 // Find the source nodes of the DAG of instructions in this basic block.
422 // Source nodes are allocas, instructions that access memory, have side
423 // effects, are terminators, or don't have a parent in the DAG of
424 // instructions.
425 //
426 // We must iterate from the first to the last instruction to preserve the
427 // order of memory accesses and other side effects. SSA operand dependencies
428 // alone do not prevent a read from moving past a write to the same memory,
429 // or an alloca from moving past an llvm.stacksave or llvm.stackrestore,
430 // which would change its lifetime.
431
432 std::stack<Instruction *> TopologicalSort;
433 SmallPtrSet<const Instruction *, 32> Visited;
434 for (auto &I : BB) {
435 // First process allocas and memory accessing, side effecting and
436 // terminating instructions.
437 if (!(isOutput(&I) || I.mayReadOrWriteMemory() || I.isTerminator() ||
439 continue;
440 LLVM_DEBUG(dbgs() << "\tReordering from source effecting instruction: ";
441 I.dump());
442 reorderDefinition(&I, TopologicalSort, Visited);
443 }
444
445 for (auto &I : BB) {
446 // Process the remaining instructions.
447 //
448 // TODO: Do more a intelligent sorting of these instructions. For example,
449 // separate between dead instructions and instructions used in another
450 // block. Use properties of the CFG the order instructions that are used
451 // in another block.
452 if (Visited.contains(&I))
453 continue;
454 LLVM_DEBUG(dbgs() << "\tReordering from source instruction: "; I.dump());
455 reorderDefinition(&I, TopologicalSort, Visited);
456 }
457
458 LLVM_DEBUG(dbgs() << "Inserting instructions into: " << BB.getName()
459 << "\n");
460 // Reorder based on the topological sort.
461 while (!TopologicalSort.empty()) {
462 auto *Instruction = TopologicalSort.top();
463 auto FirstNonPHIOrAlloca = BB.getFirstNonPHIOrAlloca();
464 if (auto *Call = dyn_cast<CallInst>(&*FirstNonPHIOrAlloca)) {
465 if (Call->getIntrinsicID() ==
466 Intrinsic::experimental_convergence_entry ||
467 Call->getIntrinsicID() == Intrinsic::experimental_convergence_loop)
468 FirstNonPHIOrAlloca++;
469 }
470 Instruction->moveBefore(FirstNonPHIOrAlloca);
471 TopologicalSort.pop();
472 }
473 }
474}
475
476void IRNormalizer::reorderDefinition(
477 Instruction *Definition, std::stack<Instruction *> &TopologicalSort,
478 SmallPtrSet<const Instruction *, 32> &Visited) const {
479 if (Visited.contains(Definition))
480 return;
481 Visited.insert(Definition);
482
483 {
484 const auto *BasicBlock = Definition->getParent();
485 const auto FirstNonPHIOrAlloca = BasicBlock->getFirstNonPHIOrAlloca();
486 if (FirstNonPHIOrAlloca == BasicBlock->end())
487 return; // TODO: Is this necessary?
488 if (Definition->comesBefore(&*FirstNonPHIOrAlloca))
489 return; // TODO: Do some kind of ordering for these instructions.
490 }
491
492 for (auto &Operand : Definition->operands()) {
493 if (auto *Op = dyn_cast<Instruction>(Operand)) {
494 if (Op->getParent() != Definition->getParent())
495 continue; // Only reorder instruction within the same basic block
496 reorderDefinition(Op, TopologicalSort, Visited);
497 }
498 }
499
500 LLVM_DEBUG(dbgs() << "\t\tNext in topological sort: "; Definition->dump());
501 if (Definition->isTerminator())
502 return;
503 if (auto *Call = dyn_cast<CallInst>(Definition)) {
504 if (Call->isMustTailCall())
505 return;
506 if (Call->getIntrinsicID() == Intrinsic::experimental_deoptimize)
507 return;
508 if (Call->getIntrinsicID() == Intrinsic::experimental_convergence_entry)
509 return;
510 if (Call->getIntrinsicID() == Intrinsic::experimental_convergence_loop)
511 return;
512 }
513 if (auto *BitCast = dyn_cast<BitCastInst>(Definition)) {
514 if (auto *Call = dyn_cast<CallInst>(BitCast->getOperand(0))) {
515 if (Call->isMustTailCall())
516 return;
517 }
518 }
519
520 TopologicalSort.emplace(Definition);
521}
522
523/// Reorders instruction's operands alphabetically. This method assumes
524/// that passed instruction is commutative. Changing the operand order
525/// in other instructions may change the semantics.
526///
527/// \param I Instruction whose operands will be reordered.
528void IRNormalizer::reorderInstructionOperandsByNames(Instruction *I) const {
529 // This method assumes that passed I is commutative,
530 // changing the order of operands in other instructions
531 // may change the semantics.
532
533 // Instruction operands for further sorting.
535
536 // Collect operands.
537 for (auto &Op : I->operands()) {
538 if (auto *V = dyn_cast<Value>(Op)) {
539 if (isa<Instruction>(V)) {
540 // This is an an instruction.
541 Operands.push_back(std::pair<std::string, Value *>(V->getName(), V));
542 } else {
543 std::string TextRepresentation;
544 raw_string_ostream Stream(TextRepresentation);
545 Op->printAsOperand(Stream, false);
546 Operands.push_back(std::pair<std::string, Value *>(Stream.str(), V));
547 }
548 }
549 }
550
551 // Sort operands.
552 sortCommutativeOperands(I, Operands);
553
554 // Reorder operands.
555 unsigned Position = 0;
556 for (auto &Op : I->operands()) {
557 Op.set(Operands[Position].second);
558 Position += 1;
559 }
560}
561
562/// Reorders PHI node's values according to the names of corresponding basic
563/// blocks.
564///
565/// \param Phi PHI node to normalize.
566void IRNormalizer::reorderPHIIncomingValues(PHINode *Phi) const {
567 // Values for further sorting.
569
570 // Collect blocks and corresponding values.
571 for (auto &BB : Phi->blocks()) {
572 Value *V = Phi->getIncomingValueForBlock(BB);
573 Values.push_back(std::pair<Value *, BasicBlock *>(V, BB));
574 }
575
576 // Sort values according to the name of a basic block.
577 llvm::sort(Values, [](const std::pair<Value *, BasicBlock *> &LHS,
578 const std::pair<Value *, BasicBlock *> &RHS) {
579 return LHS.second->getName() < RHS.second->getName();
580 });
581
582 // Swap.
583 for (unsigned i = 0; i < Values.size(); ++i) {
584 Phi->setIncomingBlock(i, Values[i].second);
585 Phi->setIncomingValue(i, Values[i].first);
586 }
587}
588
589/// Returns a vector of output instructions. An output is an instruction which
590/// has side-effects or is ReturnInst. Uses isOutput().
591///
592/// \see isOutput()
593/// \param F Function to collect outputs from.
594SmallVector<Instruction *, 16>
595IRNormalizer::collectOutputInstructions(Function &F) const {
596 // Output instructions are collected top-down in each function,
597 // any change may break the def-use chain in reordering methods.
598 SmallVector<Instruction *, 16> Outputs;
599 for (auto &I : instructions(F))
600 if (isOutput(&I))
601 Outputs.push_back(&I);
602 return Outputs;
603}
604
605/// Helper method checking whether the instruction may have side effects or is
606/// ReturnInst.
607///
608/// \param I Considered instruction.
609bool IRNormalizer::isOutput(const Instruction *I) const {
610 // Outputs are such instructions which may have side effects or is ReturnInst.
611 return I->mayHaveSideEffects() || isa<ReturnInst>(I);
612}
613
614/// Helper method checking whether the instruction has users and only
615/// immediate operands.
616///
617/// \param I Considered instruction.
618bool IRNormalizer::isInitialInstruction(const Instruction *I) const {
619 // Initial instructions are such instructions whose values are used by
620 // other instructions, yet they only depend on immediate values.
621 return !I->user_empty() && hasOnlyImmediateOperands(I);
622}
623
624/// Helper method checking whether the instruction has only immediate operands.
625///
626/// \param I Considered instruction.
627bool IRNormalizer::hasOnlyImmediateOperands(const Instruction *I) const {
628 for (const auto &Op : I->operands())
629 if (isa<Instruction>(Op))
630 return false; // Found non-immediate operand (instruction).
631 return true;
632}
633
634/// Helper method returning indices (distance from the beginning of the basic
635/// block) of outputs using the \p I (eliminates repetitions). Walks down the
636/// def-use tree recursively.
637///
638/// \param I Considered instruction.
639/// \param Visited Set of visited instructions.
640SetVector<int> IRNormalizer::getOutputFootprint(
641 Instruction *I, SmallPtrSet<const Instruction *, 32> &Visited) const {
642
643 // Vector containing indexes of outputs (no repetitions),
644 // which use I in the order of walking down the def-use tree.
645 SetVector<int> Outputs;
646
647 if (!Visited.count(I)) {
648 Visited.insert(I);
649
650 if (isOutput(I)) {
651 // Gets output instruction's parent function.
652 Function *Func = I->getParent()->getParent();
653
654 // Finds and inserts the index of the output to the vector.
655 unsigned Count = 0;
656 for (const auto &B : *Func) {
657 for (const auto &E : B) {
658 if (&E == I)
659 Outputs.insert(Count);
660 Count += 1;
661 }
662 }
663
664 // Returns to the used instruction.
665 return Outputs;
666 }
667
668 for (auto *U : I->users()) {
669 if (auto *UI = dyn_cast<Instruction>(U)) {
670 // Vector for outputs which use UI.
671 SetVector<int> OutputsUsingUI = getOutputFootprint(UI, Visited);
672 // Insert the indexes of outputs using UI.
673 Outputs.insert_range(OutputsUsingUI);
674 }
675 }
676 }
677
678 // Return to the used instruction.
679 return Outputs;
680}
681
683 FunctionAnalysisManager &AM) const {
684 IRNormalizer(Options).runOnFunction(F);
687 return PA;
688}
uint64_t uint64_t
Expand Atomic instructions
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static bool runOnFunction(Function &F, bool PostInlining)
static constexpr uint64_t hash_16_bytes(uint64_t low, uint64_t high)
static LVOptions Options
Definition LVOptions.cpp:25
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
static constexpr uint64_t hash_16_bytes(uint64_t low, uint64_t high)
#define T
SI Fold Operands
This file implements a set that has insertion order iteration characteristics.
static StringRef substr(StringRef Str, uint64_t Len)
This file defines the SmallPtrSet class.
This file defines the SmallString class.
This file defines the SmallVector class.
#define LLVM_DEBUG(...)
Definition Debug.h:119
Value * RHS
Value * LHS
Represents analyses that only rely on functions' control flow.
Definition Analysis.h:73
LLVM_ABI Intrinsic::ID getIntrinsicID() const
Returns the intrinsic ID of the intrinsic called or Intrinsic::not_intrinsic if the called function i...
bool isMustTailCall() const
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
PreservedAnalyses & preserveSet()
Mark an analysis set as preserved.
Definition Analysis.h:151
void insert_range(Range &&R)
Definition SetVector.h:182
bool insert(const value_type &X)
Insert a new element into the SetVector.
Definition SetVector.h:157
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
bool contains(ConstPtrType Ptr) const
void push_back(const T &Elt)
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
Definition Value.cpp:314
CallInst * Call
@ BasicBlock
Various leaf nodes.
Definition ISDOpcodes.h:83
NodeAddr< PhiNode * > Phi
Definition RDFGraph.h:390
NodeAddr< FuncNode * > Func
Definition RDFGraph.h:393
friend class Instruction
Iterator for Instructions in a `BasicBlock.
Definition BasicBlock.h:73
This is an optimization pass for GlobalISel generic memory operations.
RelativeUniformCounterPtr Values
Definition InstrProf.h:91
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
Definition InstrProf.h:143
void sort(IteratorTy Start, IteratorTy End)
Definition STLExtras.h:1652
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition Debug.cpp:209
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
Definition Casting.h:547
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Count
Definition InstrProf.h:145
DWARFExpression::Operation Op
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM) const