LLVM  6.0.0svn
Instrumentation.cpp
Go to the documentation of this file.
1 //===-- Instrumentation.cpp - TransformUtils Infrastructure ---------------===//
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 file defines the common initialization infrastructure for the
11 // Instrumentation library.
12 //
13 //===----------------------------------------------------------------------===//
14 
16 #include "llvm-c/Initialization.h"
17 #include "llvm/IR/IntrinsicInst.h"
18 #include "llvm/InitializePasses.h"
19 #include "llvm/PassRegistry.h"
20 
21 using namespace llvm;
22 
23 /// Moves I before IP. Returns new insert point.
25  // If I is IP, move the insert point down.
26  if (I == IP)
27  return ++IP;
28  // Otherwise, move I before IP and return IP.
29  I->moveBefore(&*IP);
30  return IP;
31 }
32 
33 /// Instrumentation passes often insert conditional checks into entry blocks.
34 /// Call this function before splitting the entry block to move instructions
35 /// that must remain in the entry block up before the split point. Static
36 /// allocas and llvm.localescape calls, for example, must remain in the entry
37 /// block.
40  assert(&BB.getParent()->getEntryBlock() == &BB);
41  for (auto I = IP, E = BB.end(); I != E; ++I) {
42  bool KeepInEntry = false;
43  if (auto *AI = dyn_cast<AllocaInst>(I)) {
44  if (AI->isStaticAlloca())
45  KeepInEntry = true;
46  } else if (auto *II = dyn_cast<IntrinsicInst>(I)) {
47  if (II->getIntrinsicID() == llvm::Intrinsic::localescape)
48  KeepInEntry = true;
49  }
50  if (KeepInEntry)
51  IP = moveBeforeInsertPoint(I, IP);
52  }
53  return IP;
54 }
55 
56 /// initializeInstrumentation - Initialize all passes in the TransformUtils
57 /// library.
73 }
74 
75 /// LLVMInitializeInstrumentation - C binding for
76 /// initializeInstrumentation.
79 }
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
void initializeDataFlowSanitizerPass(PassRegistry &)
A global registry used in conjunction with static constructors to make pluggable components (like tar...
Definition: Registry.h:45
struct LLVMOpaquePassRegistry * LLVMPassRegistryRef
Definition: Types.h:117
void initializeInstrProfilingLegacyPassPass(PassRegistry &)
Attribute unwrap(LLVMAttributeRef Attr)
Definition: Attributes.h:195
static BasicBlock::iterator moveBeforeInsertPoint(BasicBlock::iterator I, BasicBlock::iterator IP)
Moves I before IP. Returns new insert point.
void initializeEfficiencySanitizerPass(PassRegistry &)
void initializePGOInstrumentationGenLegacyPassPass(PassRegistry &)
const BasicBlock & getEntryBlock() const
Definition: Function.h:572
LLVM Basic Block Representation.
Definition: BasicBlock.h:59
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
void initializeAddressSanitizerModulePass(PassRegistry &)
void initializeInstrumentation(PassRegistry &)
Initialize all passes linked into the Instrumentation library.
void initializePGOInstrumentationUseLegacyPassPass(PassRegistry &)
void initializeAddressSanitizerPass(PassRegistry &)
Iterator for intrusive lists based on ilist_node.
iterator end()
Definition: BasicBlock.h:254
void initializeGCOVProfilerLegacyPassPass(PassRegistry &)
void initializeMemorySanitizerPass(PassRegistry &)
void initializePGOIndirectCallPromotionLegacyPassPass(PassRegistry &)
void initializeThreadSanitizerPass(PassRegistry &)
BasicBlock::iterator PrepareToSplitEntryBlock(BasicBlock &BB, BasicBlock::iterator IP)
Instrumentation passes often insert conditional checks into entry blocks.
void LLVMInitializeInstrumentation(LLVMPassRegistryRef R)
LLVMInitializeInstrumentation - C binding for initializeInstrumentation.
const Function * getParent() const
Return the enclosing method, or null if none.
Definition: BasicBlock.h:108
#define I(x, y, z)
Definition: MD5.cpp:58
void initializeBoundsCheckingLegacyPassPass(PassRegistry &)
void initializePGOMemOPSizeOptLegacyPassPass(PassRegistry &)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void initializeSanitizerCoverageModulePass(PassRegistry &)
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
Definition: PassRegistry.h:39