summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/MIRParser
diff options
context:
space:
mode:
authorAlex Lorenz <arphaman@gmail.com>2015-07-15 22:14:49 +0000
committerAlex Lorenz <arphaman@gmail.com>2015-07-15 22:14:49 +0000
commit37643a04a499a61ad800bcb526fe36e74b0b3636 (patch)
tree0b1bab2bf62904b5c896b61f5272ad7ef67546bc /llvm/lib/CodeGen/MIRParser
parentb9de106d046af99cf990f2a53b37ed804cb817f2 (diff)
downloadbcm5719-llvm-37643a04a499a61ad800bcb526fe36e74b0b3636.tar.gz
bcm5719-llvm-37643a04a499a61ad800bcb526fe36e74b0b3636.zip
MIR Serialization: Serialize references from the stack objects to named allocas.
This commit serializes the references to the named LLVM alloca instructions from the stack objects in the machine frame info. This commit adds a field 'Name' to the struct 'yaml::MachineStackObject'. This new field is used to store the name of the alloca instruction when the alloca is present and when it has a name. llvm-svn: 242339
Diffstat (limited to 'llvm/lib/CodeGen/MIRParser')
-rw-r--r--llvm/lib/CodeGen/MIRParser/MIRParser.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
index 16b0e165589..8dd76998605 100644
--- a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
@@ -108,7 +108,7 @@ public:
const yaml::MachineFunction &YamlMF,
DenseMap<unsigned, unsigned> &VirtualRegisterSlots);
- bool initializeFrameInfo(MachineFrameInfo &MFI,
+ bool initializeFrameInfo(const Function &F, MachineFrameInfo &MFI,
const yaml::MachineFunction &YamlMF);
private:
@@ -264,7 +264,7 @@ bool MIRParserImpl::initializeMachineFunction(MachineFunction &MF) {
if (initializeRegisterInfo(MF, MF.getRegInfo(), YamlMF,
PFS.VirtualRegisterSlots))
return true;
- if (initializeFrameInfo(*MF.getFrameInfo(), YamlMF))
+ if (initializeFrameInfo(*MF.getFunction(), *MF.getFrameInfo(), YamlMF))
return true;
const auto &F = *MF.getFunction();
@@ -366,7 +366,8 @@ bool MIRParserImpl::initializeRegisterInfo(
return false;
}
-bool MIRParserImpl::initializeFrameInfo(MachineFrameInfo &MFI,
+bool MIRParserImpl::initializeFrameInfo(const Function &F,
+ MachineFrameInfo &MFI,
const yaml::MachineFunction &YamlMF) {
const yaml::MachineFrameInfo &YamlMFI = YamlMF.FrameInfo;
MFI.setFrameAddressIsTaken(YamlMFI.IsFrameAddressTaken);
@@ -400,13 +401,23 @@ bool MIRParserImpl::initializeFrameInfo(MachineFrameInfo &MFI,
// Initialize the ordinary frame objects.
for (const auto &Object : YamlMF.StackObjects) {
int ObjectIdx;
+ const AllocaInst *Alloca = nullptr;
+ const yaml::StringValue &Name = Object.Name;
+ if (!Name.Value.empty()) {
+ Alloca = dyn_cast_or_null<AllocaInst>(
+ F.getValueSymbolTable().lookup(Name.Value));
+ if (!Alloca)
+ return error(Name.SourceRange.Start,
+ "alloca instruction named '" + Name.Value +
+ "' isn't defined in the function '" + F.getName() +
+ "'");
+ }
if (Object.Type == yaml::MachineStackObject::VariableSized)
- ObjectIdx =
- MFI.CreateVariableSizedObject(Object.Alignment, /*Alloca=*/nullptr);
+ ObjectIdx = MFI.CreateVariableSizedObject(Object.Alignment, Alloca);
else
ObjectIdx = MFI.CreateStackObject(
Object.Size, Object.Alignment,
- Object.Type == yaml::MachineStackObject::SpillSlot);
+ Object.Type == yaml::MachineStackObject::SpillSlot, Alloca);
MFI.setObjectOffset(ObjectIdx, Object.Offset);
// TODO: Store the mapping between object IDs and object indices to parse
// stack object references correctly.
OpenPOWER on IntegriCloud