LLVM  16.0.0git
PseudoSourceValue.cpp
Go to the documentation of this file.
1 //===-- llvm/CodeGen/PseudoSourceValue.cpp ----------------------*- C++ -*-===//
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 file implements the PseudoSourceValue class.
10 //
11 //===----------------------------------------------------------------------===//
12 
18 
19 using namespace llvm;
20 
21 static const char *const PSVNames[] = {
22  "Stack", "GOT", "JumpTable", "ConstantPool", "FixedStack",
23  "GlobalValueCallEntry", "ExternalSymbolCallEntry"};
24 
26  : Kind(Kind) {
27  AddressSpace = TM.getAddressSpaceForPseudoSourceKind(Kind);
28 }
29 
31 
32 void PseudoSourceValue::printCustom(raw_ostream &O) const {
33  if (Kind < TargetCustom)
34  O << PSVNames[Kind];
35  else
36  O << "TargetCustom" << Kind;
37 }
38 
40  if (isStack())
41  return false;
42  if (isGOT() || isConstantPool() || isJumpTable())
43  return true;
44  llvm_unreachable("Unknown PseudoSourceValue!");
45 }
46 
48  if (isStack() || isGOT() || isConstantPool() || isJumpTable())
49  return false;
50  llvm_unreachable("Unknown PseudoSourceValue!");
51 }
52 
54  return !(isGOT() || isConstantPool() || isJumpTable());
55 }
56 
58  const MachineFrameInfo *MFI) const {
59  return MFI && MFI->isImmutableObjectIndex(FI);
60 }
61 
63  if (!MFI)
64  return true;
65  return MFI->isAliasedObjectIndex(FI);
66 }
67 
69  if (!MFI)
70  return true;
71  // Spill slots will not alias any LLVM IR value.
72  return !MFI->isSpillSlotObjectIndex(FI);
73 }
74 
76  OS << "FixedStack" << FI;
77 }
78 
80  const TargetMachine &TM)
82 
84  return false;
85 }
86 
88  return false;
89 }
90 
92  return false;
93 }
94 
96  const GlobalValue *GV, const TargetMachine &TM)
97  : CallEntryPseudoSourceValue(GlobalValueCallEntry, TM), GV(GV) {}
99  const char *ES, const TargetMachine &TM)
100  : CallEntryPseudoSourceValue(ExternalSymbolCallEntry, TM), ES(ES) {}
101 
103  : TM(TMInfo), StackPSV(PseudoSourceValue::Stack, TM),
104  GOTPSV(PseudoSourceValue::GOT, TM),
105  JumpTablePSV(PseudoSourceValue::JumpTable, TM),
106  ConstantPoolPSV(PseudoSourceValue::ConstantPool, TM) {}
107 
109  return &StackPSV;
110 }
111 
113 
115  return &ConstantPoolPSV;
116 }
117 
119  return &JumpTablePSV;
120 }
121 
122 const PseudoSourceValue *
124  std::unique_ptr<FixedStackPseudoSourceValue> &V = FSValues[FI];
125  if (!V)
126  V = std::make_unique<FixedStackPseudoSourceValue>(FI, TM);
127  return V.get();
128 }
129 
130 const PseudoSourceValue *
132  std::unique_ptr<const GlobalValuePseudoSourceValue> &E =
133  GlobalCallEntries[GV];
134  if (!E)
135  E = std::make_unique<GlobalValuePseudoSourceValue>(GV, TM);
136  return E.get();
137 }
138 
139 const PseudoSourceValue *
141  std::unique_ptr<const ExternalSymbolPseudoSourceValue> &E =
142  ExternalCallEntries[ES];
143  if (!E)
144  E = std::make_unique<ExternalSymbolPseudoSourceValue>(ES, TM);
145  return E.get();
146 }
llvm::PseudoSourceValueManager::getGOT
const PseudoSourceValue * getGOT()
Return a pseudo source value referencing the global offset table (or something the like).
Definition: PseudoSourceValue.cpp:112
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::PseudoSourceValue::isAliased
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...
Definition: PseudoSourceValue.cpp:47
ErrorHandling.h
llvm::ConstantPool
Definition: ConstantPools.h:43
llvm::PseudoSourceValue::mayAlias
virtual bool mayAlias(const MachineFrameInfo *) const
Return true if the memory pointed to by this PseudoSourceValue can ever alias an LLVM IR Value.
Definition: PseudoSourceValue.cpp:53
llvm::FixedStackPseudoSourceValue::mayAlias
bool mayAlias(const MachineFrameInfo *) const override
Return true if the memory pointed to by this PseudoSourceValue can ever alias an LLVM IR Value.
Definition: PseudoSourceValue.cpp:68
llvm::PseudoSourceValueManager::getStack
const PseudoSourceValue * getStack()
Return a pseudo source value referencing the area below the stack frame of a function,...
Definition: PseudoSourceValue.cpp:108
TargetMachine.h
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::PseudoSourceValue::isStack
bool isStack() const
Definition: PseudoSourceValue.h:68
PseudoSourceValue.h
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
llvm::MachineFrameInfo::isAliasedObjectIndex
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...
Definition: MachineFrameInfo.h:686
llvm::PseudoSourceValue
Special value supplied for machine level alias analysis.
Definition: PseudoSourceValue.h:35
llvm::AddressSpace
AddressSpace
Definition: NVPTXBaseInfo.h:21
llvm::PseudoSourceValue::TargetCustom
@ TargetCustom
Definition: PseudoSourceValue.h:45
llvm::lltok::Kind
Kind
Definition: LLToken.h:18
llvm::PseudoSourceValue::isGOT
bool isGOT() const
Definition: PseudoSourceValue.h:69
llvm::FixedStackPseudoSourceValue::isConstant
bool isConstant(const MachineFrameInfo *MFI) const override
Test whether the memory pointed to by this PseudoSourceValue has a constant value.
Definition: PseudoSourceValue.cpp:57
llvm::RISCVFenceField::O
@ O
Definition: RISCVBaseInfo.h:264
llvm::GlobalValue
Definition: GlobalValue.h:44
llvm::CallEntryPseudoSourceValue::isAliased
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...
Definition: PseudoSourceValue.cpp:87
llvm::FixedStackPseudoSourceValue::isAliased
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...
Definition: PseudoSourceValue.cpp:62
llvm::CallEntryPseudoSourceValue::CallEntryPseudoSourceValue
CallEntryPseudoSourceValue(unsigned Kind, const TargetMachine &TM)
Definition: PseudoSourceValue.cpp:79
llvm::CallEntryPseudoSourceValue::isConstant
bool isConstant(const MachineFrameInfo *) const override
Test whether the memory pointed to by this PseudoSourceValue has a constant value.
Definition: PseudoSourceValue.cpp:83
llvm::TargetMachine
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:77
llvm::PseudoSourceValue::~PseudoSourceValue
virtual ~PseudoSourceValue()
llvm::CallEntryPseudoSourceValue
Definition: PseudoSourceValue.h:116
llvm::PseudoSourceValueManager::PseudoSourceValueManager
PseudoSourceValueManager(const TargetMachine &TM)
Definition: PseudoSourceValue.cpp:102
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:143
llvm::PseudoSourceValueManager::getJumpTable
const PseudoSourceValue * getJumpTable()
Return a pseudo source value referencing a jump table.
Definition: PseudoSourceValue.cpp:118
llvm::PseudoSourceValueManager::getGlobalValueCallEntry
const PseudoSourceValue * getGlobalValueCallEntry(const GlobalValue *GV)
Definition: PseudoSourceValue.cpp:131
llvm::ExternalSymbolPseudoSourceValue::ExternalSymbolPseudoSourceValue
ExternalSymbolPseudoSourceValue(const char *ES, const TargetMachine &TM)
Definition: PseudoSourceValue.cpp:98
llvm::PseudoSourceValueManager::getFixedStack
const PseudoSourceValue * getFixedStack(int FI)
Return a pseudo source value referencing a fixed stack frame entry, e.g., a spill slot.
Definition: PseudoSourceValue.cpp:123
MachineFrameInfo.h
JumpTable
MIPS Relocation Principles In there are several elements of the llvm::ISD::NodeType enum that deal with addresses and or relocations These are defined in include llvm Target TargetSelectionDAG td JumpTable
Definition: Relocation.txt:6
llvm::CallEntryPseudoSourceValue::mayAlias
bool mayAlias(const MachineFrameInfo *) const override
Return true if the memory pointed to by this PseudoSourceValue can ever alias an LLVM IR Value.
Definition: PseudoSourceValue.cpp:91
llvm::MachineFrameInfo::isSpillSlotObjectIndex
bool isSpillSlotObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a spill slot.
Definition: MachineFrameInfo.h:710
llvm::FixedStackPseudoSourceValue::printCustom
void printCustom(raw_ostream &OS) const override
Implement printing for PseudoSourceValue.
Definition: PseudoSourceValue.cpp:75
llvm::PseudoSourceValue::isConstantPool
bool isConstantPool() const
Definition: PseudoSourceValue.h:70
llvm::MachineFrameInfo::isImmutableObjectIndex
bool isImmutableObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to an immutable object.
Definition: MachineFrameInfo.h:693
llvm::MachineFrameInfo
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
Definition: MachineFrameInfo.h:105
llvm::PseudoSourceValue::isJumpTable
bool isJumpTable() const
Definition: PseudoSourceValue.h:71
PSVNames
static const char *const PSVNames[]
Definition: PseudoSourceValue.cpp:21
llvm::PseudoSourceValue::PseudoSourceValue
PseudoSourceValue(unsigned Kind, const TargetMachine &TM)
Definition: PseudoSourceValue.cpp:25
llvm::GlobalValuePseudoSourceValue::GlobalValuePseudoSourceValue
GlobalValuePseudoSourceValue(const GlobalValue *GV, const TargetMachine &TM)
Definition: PseudoSourceValue.cpp:95
TM
const char LLVMTargetMachineRef TM
Definition: PassBuilderBindings.cpp:47
raw_ostream.h
llvm::PseudoSourceValueManager::getExternalSymbolCallEntry
const PseudoSourceValue * getExternalSymbolCallEntry(const char *ES)
Definition: PseudoSourceValue.cpp:140
llvm::PseudoSourceValue::isConstant
virtual bool isConstant(const MachineFrameInfo *) const
Test whether the memory pointed to by this PseudoSourceValue has a constant value.
Definition: PseudoSourceValue.cpp:39
llvm::PseudoSourceValueManager::getConstantPool
const PseudoSourceValue * getConstantPool()
Return a pseudo source value referencing the constant pool.
Definition: PseudoSourceValue.cpp:114