1 //===- InstructionNamer.cpp - Give anonymous instructions names -----------===//
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
7 //===----------------------------------------------------------------------===//
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
14 //===----------------------------------------------------------------------===//
16 #include "llvm/Transforms/Utils/InstructionNamer.h"
17 #include "llvm/IR/Function.h"
18 #include "llvm/IR/PassManager.h"
19 #include "llvm/IR/Type.h"
24 void nameInstructions(Function
&F
) {
25 for (auto &Arg
: F
.args()) {
30 for (BasicBlock
&BB
: F
) {
34 for (Instruction
&I
: BB
) {
35 if (!I
.hasName() && !I
.getType()->isVoidTy())
43 PreservedAnalyses
InstructionNamerPass::run(Function
&F
,
44 FunctionAnalysisManager
&FAM
) {
46 return PreservedAnalyses::all();