LLVM  4.0.0
PseudoSourceValue.cpp
Go to the documentation of this file.
1 //===-- llvm/CodeGen/PseudoSourceValue.cpp ----------------------*- C++ -*-===//
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 implements the PseudoSourceValue class.
11 //
12 //===----------------------------------------------------------------------===//
13 
15 #include "llvm/ADT/STLExtras.h"
17 #include "llvm/IR/DerivedTypes.h"
18 #include "llvm/IR/LLVMContext.h"
21 using namespace llvm;
22 
23 static const char *const PSVNames[] = {
24  "Stack", "GOT", "JumpTable", "ConstantPool", "FixedStack",
25  "GlobalValueCallEntry", "ExternalSymbolCallEntry"};
26 
28 
30 
31 void PseudoSourceValue::printCustom(raw_ostream &O) const {
32  O << PSVNames[Kind];
33 }
34 
36  if (isStack())
37  return false;
38  if (isGOT() || isConstantPool() || isJumpTable())
39  return true;
40  llvm_unreachable("Unknown PseudoSourceValue!");
41 }
42 
44  if (isStack() || isGOT() || isConstantPool() || isJumpTable())
45  return false;
46  llvm_unreachable("Unknown PseudoSourceValue!");
47 }
48 
50  return !(isGOT() || isConstantPool() || isJumpTable());
51 }
52 
54  const MachineFrameInfo *MFI) const {
55  return MFI && MFI->isImmutableObjectIndex(FI);
56 }
57 
59  if (!MFI)
60  return true;
61  return MFI->isAliasedObjectIndex(FI);
62 }
63 
65  if (!MFI)
66  return true;
67  // Spill slots will not alias any LLVM IR value.
68  return !MFI->isSpillSlotObjectIndex(FI);
69 }
70 
72  OS << "FixedStack" << FI;
73 }
74 
76  : PseudoSourceValue(Kind) {}
77 
79  return false;
80 }
81 
83  return false;
84 }
85 
87  return false;
88 }
89 
91  const GlobalValue *GV)
92  : CallEntryPseudoSourceValue(GlobalValueCallEntry), GV(GV) {}
93 
95  : CallEntryPseudoSourceValue(ExternalSymbolCallEntry), ES(ES) {}
96 
98  : StackPSV(PseudoSourceValue::Stack), GOTPSV(PseudoSourceValue::GOT),
99  JumpTablePSV(PseudoSourceValue::JumpTable),
100  ConstantPoolPSV(PseudoSourceValue::ConstantPool) {}
101 
103  return &StackPSV;
104 }
105 
107 
109  return &ConstantPoolPSV;
110 }
111 
113  return &JumpTablePSV;
114 }
115 
117  std::unique_ptr<FixedStackPseudoSourceValue> &V = FSValues[FI];
118  if (!V)
119  V = llvm::make_unique<FixedStackPseudoSourceValue>(FI);
120  return V.get();
121 }
122 
123 const PseudoSourceValue *
125  std::unique_ptr<const GlobalValuePseudoSourceValue> &E =
126  GlobalCallEntries[GV];
127  if (!E)
128  E = llvm::make_unique<GlobalValuePseudoSourceValue>(GV);
129  return E.get();
130 }
131 
132 const PseudoSourceValue *
134  std::unique_ptr<const ExternalSymbolPseudoSourceValue> &E =
135  ExternalCallEntries[ES];
136  if (!E)
137  E = llvm::make_unique<ExternalSymbolPseudoSourceValue>(ES);
138  return E.get();
139 }
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
bool isAliased(const MachineFrameInfo *) const override
Test whether the memory pointed to by this PseudoSourceValue may also be pointed to by an LLVM IR Val...
bool isImmutableObjectIndex(int ObjectIdx) const
isImmutableObjectIndex - Returns true if the specified index corresponds to an immutable object...
bool isConstant(const MachineFrameInfo *MFI) const override
Test whether the memory pointed to by this PseudoSourceValue has a constant value.
bool mayAlias(const MachineFrameInfo *) const override
Return true if the memory pointed to by this PseudoSourceValue can ever alias an LLVM IR Value...
const PseudoSourceValue * getFixedStack(int FI)
Return a pseudo source value referencing a fixed stack frame entry, e.g., a spill slot...
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
bool isSpillSlotObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a spill slot.
virtual bool mayAlias(const MachineFrameInfo *) const
Return true if the memory pointed to by this PseudoSourceValue can ever alias an LLVM IR Value...
const PseudoSourceValue * getExternalSymbolCallEntry(const char *ES)
bool isAliasedObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to an object that might be pointed to by an LLVM IR v...
GlobalValuePseudoSourceValue(const GlobalValue *GV)
virtual bool isConstant(const MachineFrameInfo *) const
Test whether the memory pointed to by this PseudoSourceValue has a constant value.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Special value supplied for machine level alias analysis.
const PseudoSourceValue * getJumpTable()
Return a pseudo source value referencing a jump table.
const PseudoSourceValue * getGlobalValueCallEntry(const GlobalValue *GV)
const PseudoSourceValue * getGOT()
Return a pseudo source value referencing the global offset table (or something the like)...
static const char *const PSVNames[]
bool isAliased(const MachineFrameInfo *MFI) const override
Test whether the memory pointed to by this PseudoSourceValue may also be pointed to by an LLVM IR Val...
const unsigned Kind
const PseudoSourceValue * getStack()
Return a pseudo source value referencing the area below the stack frame of a function, e.g., the argument space.
bool isConstant(const MachineFrameInfo *) const override
Test whether the memory pointed to by this PseudoSourceValue has a constant value.
void printCustom(raw_ostream &OS) const override
Implement printing for PseudoSourceValue.
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:44
bool mayAlias(const MachineFrameInfo *) const override
Return true if the memory pointed to by this PseudoSourceValue can ever alias an LLVM IR Value...
const PseudoSourceValue * getConstantPool()
Return a pseudo source value referencing the constant pool.
virtual bool isAliased(const MachineFrameInfo *) const
Test whether the memory pointed to by this PseudoSourceValue may also be pointed to by an LLVM IR Val...