LLVM
8.0.1
lib
Transforms
Utils
InstructionNamer.cpp
Go to the documentation of this file.
1
//===- InstructionNamer.cpp - Give anonymous instructions names -----------===//
2
//
3
// The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
//
10
// This is a little utility pass that gives instructions names, this is mostly
11
// useful when diffing the effect of an optimization because deleting an
12
// unnamed instruction can change all other instruction numbering, making the
13
// diff very noisy.
14
//
15
//===----------------------------------------------------------------------===//
16
17
#include "
llvm/IR/Function.h
"
18
#include "
llvm/IR/Type.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:32
llvm
This class represents lattice values for constants.
Definition:
AllocatorList.h:24
Type.h
F
F(f)
llvm::Function
Definition:
Function.h:60
llvm::Value::setName
void setName(const Twine &Name)
Change the name of the value.
Definition:
Value.cpp:285
llvm::Instruction
Definition:
Instruction.h:44
llvm::Intrinsic::ID
ID
Definition:
Intrinsics.h:37
Info
Analysis containing CSE Info
Definition:
CSEInfo.cpp:21
runOnFunction
static bool runOnFunction(Function &F, bool PostInlining)
Definition:
EntryExitInstrumenter.cpp:66
llvm::Value::hasName
bool hasName() const
Definition:
Value.h:251
llvm::BasicBlock
LLVM Basic Block Representation.
Definition:
BasicBlock.h:58
Utils.h
llvm::AnalysisUsage
Represent the analysis usage information of a pass.
Definition:
PassAnalysisSupport.h:43
llvm::FunctionPass
FunctionPass class - This class is used to implement most global optimizations.
Definition:
Pass.h:285
INITIALIZE_PASS
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Definition:
PassSupport.h:34
llvm::AnalysisUsage::setPreservesAll
void setPreservesAll()
Set by analyses that do not transform their input at all.
Definition:
PassAnalysisSupport.h:121
Pass.h
Function.h
Arg
amdgpu Simplify well known AMD library false Value Value * Arg
Definition:
AMDGPULibCalls.cpp:220
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:689
Generated on Sun Dec 20 2020 13:59:46 for LLVM by
1.8.13