[llvm-commits] [dragonegg] r137962 - /dragonegg/trunk/src/Constants.cpp
Duncan Sands
baldrick at free.fr
Thu Aug 18 11:07:33 PDT 2011
Author: baldrick
Date: Thu Aug 18 13:07:33 2011
New Revision: 137962
URL: http://llvm.org/viewvc/llvm-project?rev=137962&view=rev
Log:
When having trouble because the constant doesn't fit well in
the range of bits it is supposed to fill, immediately fall
back to turning it into a bunch of bytes, rather than first
trying to turn it into a (possibly giant) integer. There
doesn't seem to be much advantage to using an integer, and
avoiding funky integers means PR10641 trouble is avoided.
Modified:
dragonegg/trunk/src/Constants.cpp
Modified: dragonegg/trunk/src/Constants.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Constants.cpp?rev=137962&r1=137961&r2=137962&view=diff
==============================================================================
--- dragonegg/trunk/src/Constants.cpp (original)
+++ dragonegg/trunk/src/Constants.cpp Thu Aug 18 13:07:33 2011
@@ -1028,21 +1028,16 @@
assert(isSafeToReturnContentsDirectly(TD) && "Unit over aligned?");
return C;
}
- assert(R.getWidth() % BITS_PER_UNIT == 0 && "Boundaries not aligned?");
- unsigned Units = R.getWidth() / BITS_PER_UNIT;
- // Turn the contents into a bunch of bits. Remember the returned value as
+ // Turn the contents into a bunch of bytes. Remember the returned value as
// an optimization in case we are called again.
// TODO: If the contents only need to be truncated and have struct or array
// type then we could try to do the truncation by dropping or modifying the
// last elements of the constant, maybe yielding something less horrible.
- C = getAsBits();
+ assert(R.getWidth() % BITS_PER_UNIT == 0 && "Boundaries not aligned?");
+ unsigned Units = R.getWidth() / BITS_PER_UNIT;
+ C = InterpretAsType(C, GetUnitType(Context, Units), R.getFirst() - Starts,
+ Folder);
Starts = R.getFirst();
- if (isSafeToReturnContentsDirectly(TD))
- return C;
- // The integer type used to hold the bits was too big (for example an i24
- // typically occupies 32 bits so is too big for a range of 24 bits). Turn
- // it into an array of bytes instead.
- C = InterpretAsType(C, GetUnitType(Context, Units), 0, Folder);
assert(isSafeToReturnContentsDirectly(TD) && "Unit over aligned?");
return C;
}
@@ -1054,6 +1049,12 @@
/// disjoint from this one). After this the range will be the convex hull of
/// the ranges of the two fields.
void FieldContents::JoinWith(const FieldContents &S) {
+ if (S.R.empty())
+ return;
+ if (R.empty()) {
+ *this = S;
+ return;
+ }
// Consider the contents of the fields to be bunches of bits and paste them
// together. This can result in a nasty integer constant expression, but as
// we only get here for bitfields that's mostly harmless.
More information about the llvm-commits
mailing list