[llvm-commits] [llvm] r98379 - in /llvm/trunk: include/llvm/MC/MCAssembler.h lib/MC/MCMachOStreamer.cpp
Daniel Dunbar
daniel at zuster.org
Fri Mar 12 13:00:39 PST 2010
Author: ddunbar
Date: Fri Mar 12 15:00:38 2010
New Revision: 98379
URL: http://llvm.org/viewvc/llvm-project?rev=98379&view=rev
Log:
MC: Add MCAssembler::addFixup, which enforces that fixups are added in order.
Modified:
llvm/trunk/include/llvm/MC/MCAssembler.h
llvm/trunk/lib/MC/MCMachOStreamer.cpp
Modified: llvm/trunk/include/llvm/MC/MCAssembler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAssembler.h?rev=98379&r1=98378&r2=98379&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCAssembler.h (original)
+++ llvm/trunk/include/llvm/MC/MCAssembler.h Fri Mar 12 15:00:38 2010
@@ -162,6 +162,13 @@
/// @name Fixup Access
/// @{
+ void addFixup(MCAsmFixup Fixup) {
+ // Enforce invariant that fixups are in offset order.
+ assert(Fixups.empty() || Fixup.Offset > Fixups.back().Offset &&
+ "Fixups must be added in order!");
+ Fixups.push_back(Fixup);
+ }
+
std::vector<MCAsmFixup> &getFixups() { return Fixups; }
const std::vector<MCAsmFixup> &getFixups() const { return Fixups; }
Modified: llvm/trunk/lib/MC/MCMachOStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCMachOStreamer.cpp?rev=98379&r1=98378&r2=98379&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCMachOStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCMachOStreamer.cpp Fri Mar 12 15:00:38 2010
@@ -327,9 +327,8 @@
for (unsigned i = 0; i != Size; ++i)
DF->getContents().push_back(uint8_t(AbsValue >> (i * 8)));
} else {
- DF->getFixups().push_back(MCAsmFixup(DF->getContents().size(),
- *AddValueSymbols(Value),
- MCFixup::getKindForSize(Size)));
+ DF->addFixup(MCAsmFixup(DF->getContents().size(), *AddValueSymbols(Value),
+ MCFixup::getKindForSize(Size)));
DF->getContents().resize(DF->getContents().size() + Size, 0);
}
}
@@ -388,9 +387,8 @@
DF = new MCDataFragment(CurSectionData);
for (unsigned i = 0, e = Fixups.size(); i != e; ++i) {
MCFixup &F = Fixups[i];
- DF->getFixups().push_back(MCAsmFixup(DF->getContents().size()+F.getOffset(),
- *F.getValue(),
- F.getKind()));
+ DF->addFixup(MCAsmFixup(DF->getContents().size()+F.getOffset(),
+ *F.getValue(), F.getKind()));
}
DF->getContents().append(Code.begin(), Code.end());
}
More information about the llvm-commits
mailing list