[cfe-commits] patch for MSVC compilation errors
spam at erwincoumans.com
spam at erwincoumans.com
Tue May 19 08:10:40 PDT 2009
Current llvm trunk SVN revision 72106, combined with current clang trunk SVN
revision 72109, has compilation errors on MSVC 2005 using cmake:
cmake ../llvm_trunk . -G "Microsoft Visual Studio 8 2005"
Errors:
error C2888: 'LiveIntervals::InstrSlots' : symbol cannot be defined within
namespace 'llvm'
error C2888: 'LiveIntervals::SRInfo' : symbol cannot be defined within
namespace 'llvm'
After fixing those, a link error for 'createSpiller' happens.
Attached is a patch that makes the current llvm/clang trunk
compile,link,run,
Thanks,
Erwin
-------------- next part --------------
Index: include/llvm/CodeGen/LiveInterval.h
===================================================================
--- include/llvm/CodeGen/LiveInterval.h (revision 72109)
+++ include/llvm/CodeGen/LiveInterval.h (working copy)
@@ -30,7 +30,7 @@
namespace llvm {
class MachineInstr;
class TargetRegisterInfo;
- struct LiveInterval;
+ class LiveInterval;
/// VNInfo - If the value number definition is undefined (e.g. phi
/// merge point), it contains ~0u,x. If the value number is not in use, it
@@ -101,7 +101,9 @@
/// LiveInterval - This class represents some number of live ranges for a
/// register or value. This class also contains a bit of register allocator
/// state.
- struct LiveInterval {
+ class LiveInterval {
+ public:
+
typedef SmallVector<LiveRange,4> Ranges;
typedef SmallVector<VNInfo*,4> VNInfoList;
Index: include/llvm/CodeGen/LiveIntervalAnalysis.h
===================================================================
--- include/llvm/CodeGen/LiveIntervalAnalysis.h (revision 72109)
+++ include/llvm/CodeGen/LiveIntervalAnalysis.h (working copy)
@@ -54,6 +54,24 @@
return LHS.first < RHS.first;
}
};
+
+ struct InstrSlots {
+ enum {
+ LOAD = 0,
+ USE = 1,
+ DEF = 2,
+ STORE = 3,
+ NUM = 4
+ };
+ };
+
+ /// SRInfo - Spill / restore info.
+ struct SRInfo {
+ int index;
+ unsigned vreg;
+ bool canFold;
+ SRInfo(int i, unsigned vr, bool f) : index(i), vreg(vr), canFold(f) {};
+ };
class LiveIntervals : public MachineFunctionPass {
MachineFunction* mf_;
@@ -96,15 +114,7 @@
static char ID; // Pass identification, replacement for typeid
LiveIntervals() : MachineFunctionPass(&ID) {}
- struct InstrSlots {
- enum {
- LOAD = 0,
- USE = 1,
- DEF = 2,
- STORE = 3,
- NUM = 4
- };
- };
+
static unsigned getBaseIndex(unsigned index) {
return index - (index % InstrSlots::NUM);
@@ -398,7 +408,7 @@
/// within a single basic block.
bool intervalIsInOneMBB(const LiveInterval &li) const;
- private:
+ public://private:
/// computeIntervals - Compute live intervals.
void computeIntervals();
@@ -473,13 +483,7 @@
/// has any super register that's allocatable.
bool hasAllocatableSuperReg(unsigned Reg) const;
- /// SRInfo - Spill / restore info.
- struct SRInfo {
- int index;
- unsigned vreg;
- bool canFold;
- SRInfo(int i, unsigned vr, bool f) : index(i), vreg(vr), canFold(f) {};
- };
+
bool alsoFoldARestore(int Id, int index, unsigned vr,
BitVector &RestoreMBBs,
Index: lib/CodeGen/SimpleRegisterCoalescing.cpp
===================================================================
--- lib/CodeGen/SimpleRegisterCoalescing.cpp (revision 72109)
+++ lib/CodeGen/SimpleRegisterCoalescing.cpp (working copy)
@@ -2598,7 +2598,7 @@
static bool isZeroLengthInterval(LiveInterval *li) {
for (LiveInterval::Ranges::const_iterator
i = li->ranges.begin(), e = li->ranges.end(); i != e; ++i)
- if (i->end - i->start > LiveIntervals::InstrSlots::NUM)
+ if (i->end - i->start > InstrSlots::NUM)
return false;
return true;
}
Index: lib/CodeGen/SimpleRegisterCoalescing.h
===================================================================
--- lib/CodeGen/SimpleRegisterCoalescing.h (revision 72109)
+++ lib/CodeGen/SimpleRegisterCoalescing.h (working copy)
@@ -133,7 +133,7 @@
if (!li_->hasInterval(Reg))
return 0;
return li_->getApproximateInstructionCount(li_->getInterval(Reg)) *
- LiveIntervals::InstrSlots::NUM;
+ InstrSlots::NUM;
}
/// print - Implement the dump method.
Index: lib/CodeGen/Spiller.cpp
===================================================================
--- lib/CodeGen/Spiller.cpp (revision 72109)
+++ lib/CodeGen/Spiller.cpp (working copy)
@@ -162,7 +162,7 @@
MachineBasicBlock::iterator storeInstItr(mi);
++storeInstItr;
MachineInstr *storeInst = &*storeInstItr;
- unsigned storeInstIdx = miIdx + LiveIntervals::InstrSlots::NUM;
+ unsigned storeInstIdx = miIdx + InstrSlots::NUM;
assert(lis->getInstructionFromIndex(storeInstIdx) == 0 &&
"Store inst index already in use.");
@@ -185,7 +185,7 @@
MachineBasicBlock::iterator loadInstItr(mi);
--loadInstItr;
MachineInstr *loadInst = &*loadInstItr;
- unsigned loadInstIdx = miIdx - LiveIntervals::InstrSlots::NUM;
+ unsigned loadInstIdx = miIdx - InstrSlots::NUM;
assert(lis->getInstructionFromIndex(loadInstIdx) == 0 &&
"Load inst index already in use.");
@@ -197,10 +197,12 @@
};
+
+
}
-llvm::Spiller* llvm::createSpiller(MachineFunction *mf, LiveIntervals *lis,
+Spiller* llvm::createSpiller(MachineFunction *mf, LiveIntervals *lis,
VirtRegMap *vrm) {
return new TrivialSpiller(mf, lis, vrm);
}
Index: lib/CodeGen/Spiller.h
===================================================================
--- lib/CodeGen/Spiller.h (revision 72109)
+++ lib/CodeGen/Spiller.h (working copy)
@@ -11,6 +11,9 @@
#define LLVM_CODEGEN_SPILLER_H
#include <vector>
+#include "llvm/CodeGen/MachineFunction.h"
+#include "llvm/CodeGen/LiveIntervalAnalysis.h"
+#include "VirtRegMap.h"
namespace llvm {
@@ -21,12 +24,12 @@
class Spiller {
public:
virtual ~Spiller() = 0;
- virtual std::vector<class LiveInterval*> spill(class LiveInterval *li) = 0;
+ virtual std::vector< LiveInterval*> spill(LiveInterval *li) = 0;
};
+ /// Create and return a spiller object, as specified on the command line.
+ Spiller* createSpiller( MachineFunction *mf, LiveIntervals *li, VirtRegMap *vrm);
- /// Create and return a spiller object, as specified on the command line.
- Spiller* createSpiller(class MachineFunction *mf, class LiveIntervals *li,
- class VirtRegMap *vrm);
}
+
#endif
Index: lib/CodeGen/StrongPHIElimination.cpp
===================================================================
--- lib/CodeGen/StrongPHIElimination.cpp (revision 72109)
+++ lib/CodeGen/StrongPHIElimination.cpp (working copy)
@@ -1027,7 +1027,7 @@
if (MBB != PInstr->getParent() &&
InputI.liveAt(LI.getMBBStartIdx(PInstr->getParent())) &&
InputI.expiredAt(LI.getInstructionIndex(PInstr) +
- LiveIntervals::InstrSlots::NUM))
+ InstrSlots::NUM))
InputI.removeRange(LI.getMBBStartIdx(PInstr->getParent()),
LI.getInstructionIndex(PInstr),
true);
More information about the cfe-commits
mailing list