LLVM 22.0.0git
InstructionNamer.cpp
Go to the documentation of this file.
1//===- InstructionNamer.cpp - Give anonymous instructions names -----------===//
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 is a little utility pass that gives instructions names, this is mostly
10// useful when diffing the effect of an optimization because deleting an
11// unnamed instruction can change all other instruction numbering, making the
12// diff very noisy.
13//
14//===----------------------------------------------------------------------===//
15
17#include "llvm/IR/Function.h"
18#include "llvm/IR/PassManager.h"
19#include "llvm/IR/Type.h"
20
21using namespace llvm;
22
24 for (Argument &Arg : F.args()) {
25 if (!Arg.hasName())
26 Arg.setName("arg");
27 }
28
29 for (BasicBlock &BB : F) {
30 if (!BB.hasName())
31 BB.setName("bb");
32
33 for (Instruction &I : BB) {
34 if (!I.hasName() && !I.getType()->isVoidTy())
35 I.setName("i");
36 }
37 }
38}
39
This header defines various interfaces for pass management in LLVM.
static void nameInstructions(Function &F)
#define F(x, y, z)
Definition MD5.cpp:55
#define I(x, y, z)
Definition MD5.cpp:58
FunctionAnalysisManager FAM
This class represents an incoming formal argument to a Function.
Definition Argument.h:32
LLVM Basic Block Representation.
Definition BasicBlock.h:62
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition Analysis.h:118
This is an optimization pass for GlobalISel generic memory operations.
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
PreservedAnalyses run(Function &, FunctionAnalysisManager &)