LLVM
10.0.0
lib
Transforms
Utils
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
16
#include "
llvm/IR/Function.h
"
17
#include "
llvm/IR/Type.h
"
18
#include "
llvm/InitializePasses.h
"
19
#include "
llvm/Pass.h
"
20
#include "
llvm/Transforms/Utils.h
"
21
using namespace
llvm
;
22
23
namespace
{
24
struct
InstNamer :
public
FunctionPass
{
25
static
char
ID
;
// Pass identification, replacement for typeid
26
InstNamer() :
FunctionPass
(ID) {
27
initializeInstNamerPass
(*
PassRegistry::getPassRegistry
());
28
}
29
30
void
getAnalysisUsage(
AnalysisUsage
&
Info
)
const override
{
31
Info.
setPreservesAll
();
32
}
33
34
bool
runOnFunction
(
Function
&
F
)
override
{
35
for
(
auto
&
Arg
: F.
args
())
36
if
(!
Arg
.hasName())
37
Arg
.setName(
"arg"
);
38
39
for
(
BasicBlock
&BB : F) {
40
if
(!BB.hasName())
41
BB.setName(
"bb"
);
42
43
for
(
Instruction
&
I
: BB)
44
if
(!
I
.hasName() && !
I
.getType()->isVoidTy())
45
I
.setName(
"tmp"
);
46
}
47
return
true
;
48
}
49
};
50
51
char
InstNamer::ID
= 0;
52
}
53
54
INITIALIZE_PASS
(InstNamer,
"instnamer"
,
55
"Assign names to anonymous instructions"
,
false
,
false
)
56
char
&
llvm
::
InstructionNamerID
= InstNamer::ID;
57
//===----------------------------------------------------------------------===//
58
//
59
// InstructionNamer - Give any unnamed non-void instructions "tmp" names.
60
//
61
FunctionPass
*
llvm
::
createInstructionNamerPass
() {
62
return
new
InstNamer();
63
}
llvm::PassRegistry::getPassRegistry
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Definition:
PassRegistry.cpp:31
llvm
This class represents lattice values for constants.
Definition:
AllocatorList.h:23
Type.h
F
F(f)
llvm::Function
Definition:
Function.h:59
llvm::Intrinsic::ID
unsigned ID
Definition:
TargetTransformInfo.h:39
llvm::Instruction
Definition:
Instruction.h:43
Info
Analysis containing CSE Info
Definition:
CSEInfo.cpp:25
runOnFunction
static bool runOnFunction(Function &F, bool PostInlining)
Definition:
EntryExitInstrumenter.cpp:66
llvm::BasicBlock
LLVM Basic Block Representation.
Definition:
BasicBlock.h:57
Utils.h
InitializePasses.h
llvm::AnalysisUsage
Represent the analysis usage information of a pass.
Definition:
PassAnalysisSupport.h:42
llvm::FunctionPass
FunctionPass class - This class is used to implement most global optimizations.
Definition:
Pass.h:282
Arg
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
Definition:
AMDGPULibCalls.cpp:224
INITIALIZE_PASS
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Definition:
PassSupport.h:33
llvm::AnalysisUsage::setPreservesAll
void setPreservesAll()
Set by analyses that do not transform their input at all.
Definition:
PassAnalysisSupport.h:120
Pass.h
Function.h
llvm::initializeInstNamerPass
void initializeInstNamerPass(PassRegistry &)
I
#define I(x, y, z)
Definition:
MD5.cpp:58
llvm::InstructionNamerID
char & InstructionNamerID
llvm::createInstructionNamerPass
FunctionPass * createInstructionNamerPass()
char
llvm::Function::args
iterator_range< arg_iterator > args()
Definition:
Function.h:730
Generated on Tue Mar 24 2020 13:15:03 for LLVM by
1.8.13