Skip to content

Commit db901f2

Browse files
author
Wesley Peck
committed
Commit 122778 broke DWARF debug output when using the MBlaze backend. Fixed by overriding TargetFrameInfo::getFrameIndexOffset to take into account the new frame index information.
llvm-svn: 122889
1 parent a1c6635 commit db901f2

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

llvm/lib/Target/MBlaze/MBlazeFrameInfo.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,15 @@ namespace llvm {
4343
static void replaceFrameIndexes(MachineFunction &MF,
4444
SmallVector<std::pair<int,int64_t>, 16> &FR) {
4545
MachineFrameInfo *MFI = MF.getFrameInfo();
46+
MBlazeFunctionInfo *MBlazeFI = MF.getInfo<MBlazeFunctionInfo>();
4647
const SmallVector<std::pair<int,int64_t>, 16>::iterator FRB = FR.begin();
4748
const SmallVector<std::pair<int,int64_t>, 16>::iterator FRE = FR.end();
4849

4950
SmallVector<std::pair<int,int64_t>, 16>::iterator FRI = FRB;
5051
for (; FRI != FRE; ++FRI) {
5152
MFI->RemoveStackObject(FRI->first);
5253
int NFI = MFI->CreateFixedObject(4, FRI->second, true);
54+
MBlazeFI->recordReplacement(FRI->first, NFI);
5355

5456
for (MachineFunction::iterator MB=MF.begin(), ME=MF.end(); MB!=ME; ++MB) {
5557
MachineBasicBlock::iterator MBB = MB->begin();
@@ -321,6 +323,14 @@ static void determineFrameLayout(MachineFunction &MF) {
321323
DEBUG(dbgs() << "Aligned Frame Size: " << FrameSize << "\n" );
322324
}
323325

326+
int MBlazeFrameInfo::getFrameIndexOffset(const MachineFunction &MF, int FI)
327+
const {
328+
const MBlazeFunctionInfo *MBlazeFI = MF.getInfo<MBlazeFunctionInfo>();
329+
if (MBlazeFI->hasReplacement(FI))
330+
FI = MBlazeFI->getReplacement(FI);
331+
return TargetFrameInfo::getFrameIndexOffset(MF,FI);
332+
}
333+
324334
// hasFP - Return true if the specified function should have a dedicated frame
325335
// pointer register. This is true if the function has variable sized allocas or
326336
// if frame pointer elimination is disabled.

llvm/lib/Target/MBlaze/MBlazeFrameInfo.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ class MBlazeFrameInfo : public TargetFrameInfo {
4242

4343
bool hasFP(const MachineFunction &MF) const;
4444

45+
int getFrameIndexOffset(const MachineFunction &MF, int FI) const;
46+
4547
virtual void processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
4648
RegScavenger *RS) const;
4749
};

llvm/lib/Target/MBlaze/MBlazeMachineFunction.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#ifndef MBLAZE_MACHINE_FUNCTION_INFO_H
1515
#define MBLAZE_MACHINE_FUNCTION_INFO_H
1616

17+
#include "llvm/ADT/DenseMap.h"
1718
#include "llvm/ADT/SmallVector.h"
1819
#include "llvm/ADT/VectorExtras.h"
1920
#include "llvm/CodeGen/MachineFunction.h"
@@ -63,6 +64,11 @@ class MBlazeFunctionInfo : public MachineFunctionInfo {
6364
SmallVector<MBlazeFIHolder, 4> FnStoreVarArgs;
6465
bool HasStoreVarArgs;
6566

67+
// When determining the final stack layout some of the frame indexes may
68+
// be replaced by new frame indexes that reside in the caller's stack
69+
// frame. The replacements are recorded in this structure.
70+
DenseMap<int,int> FIReplacements;
71+
6672
/// SRetReturnReg - Some subtargets require that sret lowering includes
6773
/// returning the value of the returned struct in a register. This field
6874
/// holds the virtual register into which the sret argument is passed.
@@ -115,6 +121,18 @@ class MBlazeFunctionInfo : public MachineFunctionInfo {
115121

116122
const SmallVector<int, 16>& getLiveIn() const { return LiveInFI; }
117123

124+
void recordReplacement(int OFI, int NFI) {
125+
FIReplacements.insert(std::make_pair(OFI,NFI));
126+
}
127+
128+
bool hasReplacement(int OFI) const {
129+
return FIReplacements.find(OFI) != FIReplacements.end();
130+
}
131+
132+
int getReplacement(int OFI) const {
133+
return FIReplacements.lookup(OFI);
134+
}
135+
118136
void recordLoadArgsFI(int FI, int SPOffset) {
119137
if (!HasLoadArgs) HasLoadArgs=true;
120138
FnLoadArgs.push_back(MBlazeFIHolder(FI, SPOffset));

0 commit comments

Comments
 (0)