aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShuxin Yang <shuxin.llvm@gmail.com>2012-12-19 01:10:17 +0000
committerShuxin Yang <shuxin.llvm@gmail.com>2012-12-19 01:10:17 +0000
commitd6b51d1dc158b82cab2e2a77b6c4b4fddb156952 (patch)
tree5be261eaea81803e9ea78742aa423c6d34453419
parent5469f605fe86edcfb6d3f0e36f3e3ce0254334cc (diff)
Make sure the buffer, which containas an instance of APFloat, has proper alignment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170486 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/InstCombine/InstCombineAddSub.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineAddSub.cpp b/lib/Transforms/InstCombine/InstCombineAddSub.cpp
index bd642dea36..30d7534363 100644
--- a/lib/Transforms/InstCombine/InstCombineAddSub.cpp
+++ b/lib/Transforms/InstCombine/InstCombineAddSub.cpp
@@ -65,11 +65,11 @@ namespace {
private:
bool insaneIntVal(int V) { return V > 4 || V < -4; }
APFloat *getFpValPtr(void)
- { return reinterpret_cast<APFloat*>(&FpValBuf[0]); }
+ { return reinterpret_cast<APFloat*>(&FpValBuf.buffer[0]); }
const APFloat &getFpVal(void) const {
assert(IsFp && BufHasFpVal && "Incorret state");
- return *reinterpret_cast<const APFloat*>(&FpValBuf[0]);
+ return *reinterpret_cast<const APFloat*>(&FpValBuf.buffer[0]);
}
APFloat &getFpVal(void)
@@ -78,6 +78,7 @@ namespace {
bool isInt() const { return !IsFp; }
private:
+
bool IsFp;
// True iff FpValBuf contains an instance of APFloat.
@@ -88,11 +89,8 @@ namespace {
// two instructions. So the range of <IntVal> falls in [-4, 4]. APInt
// is overkill of this end.
short IntVal;
-
- union {
- char FpValBuf[sizeof(APFloat)];
- int dummy; // So this structure has at least 4-byte alignment.
- };
+
+ AlignedCharArrayUnion<APFloat> FpValBuf;
};
/// FAddend is used to represent floating-point addend. An addend is