Go to the documentation of this file.
28 using namespace sampleprof;
29 using namespace sampleprofutil;
31 #define DEBUG_TYPE "mirfs-discriminators"
36 "Add MIR Flow Sensitive Discriminators",
56 Ret ^= updateHash(
BB.getName());
57 Ret ^= updateHash(DIL->getScope()->getSubprogram()->getLinkageName());
58 for (DIL = DIL->getInlinedAt(); DIL; DIL = DIL->getInlinedAt()) {
60 Ret ^= updateHash(DIL->getScope()->getSubprogram()->getLinkageName());
70 bool MIRAddFSDiscriminators::runOnMachineFunction(
MachineFunction &MF) {
77 using LocationDiscriminator = std::tuple<StringRef, unsigned, unsigned>;
80 using LocationDiscriminatorCurrPassMap =
83 LocationDiscriminatorBBMap LDBM;
84 LocationDiscriminatorCurrPassMap LDCM;
87 unsigned BitMaskBefore =
getN1Bits(LowBit);
91 unsigned BitMaskThisPass = BitMaskNow ^ BitMaskBefore;
101 unsigned LineNo = DIL->getLine();
106 auto &BBMap = LDBM[
LD];
107 auto R = BBMap.insert(&
BB);
108 if (BBMap.size() == 1)
111 unsigned DiscriminatorCurrPass;
112 DiscriminatorCurrPass =
R.second ? ++LDCM[
LD] : LDCM[
LD];
113 DiscriminatorCurrPass = DiscriminatorCurrPass << LowBit;
115 DiscriminatorCurrPass &= BitMaskThisPass;
120 << DIL->getFilename() <<
":" << DIL->getLine() <<
":"
121 << DIL->getColumn() <<
":" << Discriminator <<
" "
126 I.setDebugLoc(NewDIL);
128 LLVM_DEBUG(
dbgs() << DIL->getFilename() <<
":" << DIL->getLine() <<
":"
129 << DIL->getColumn() <<
": add FS discriminator, from "
130 << Discriminator <<
" -> " << NewD <<
"\n");
137 LLVM_DEBUG(
dbgs() <<
"Num of FS Discriminators: " << NumNewD <<
"\n");
This is an optimization pass for GlobalISel generic memory operations.
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
cl::opt< bool > EnableFSDiscriminator
static unsigned getN1Bits(int N)
const DILocation * cloneWithDiscriminator(unsigned Discriminator) const
Returns a new DILocation with updated Discriminator.
char & MIRAddFSDiscriminatorsID
This pass adds flow sensitive discriminators.
static uint64_t getCallStackHash(const MachineBasicBlock &BB, const MachineInstr &MI, const DILocation *DIL)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
void createFSDiscriminatorVariable(Module *M)
Create a global variable to flag FSDiscriminators are used.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Implements a dense probed hash-table based set.
Representation of each machine instruction.
StringRef - Represent a constant reference to a string, i.e.
StringRef getName() const
Return a constant reference to the value's name.
FunctionPass * createMIRAddFSDiscriminatorsPass(sampleprof::FSDiscriminatorPass P)
Add Flow Sensitive Discriminators.
Function & getFunction()
Return the LLVM function that this machine code represents.
bool shouldEmitDebugInfoForProfiling() const
Returns true if we should emit debug info for profiling.
std::string to_string(const T &Value)
FunctionPass class - This class is used to implement most global optimizations.
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
uint64_t MD5Hash(StringRef Str)
Helper to compute and return lower 64 bits of the given string's MD5 hash.