[llvm-commits] [llvm] r170486 - /llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp
Shuxin Yang
shuxin.llvm at gmail.com
Tue Dec 18 17:10:17 PST 2012
Author: shuxin_yang
Date: Tue Dec 18 19:10:17 2012
New Revision: 170486
URL: http://llvm.org/viewvc/llvm-project?rev=170486&view=rev
Log:
Make sure the buffer, which containas an instance of APFloat, has proper alignment.
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp?rev=170486&r1=170485&r2=170486&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp Tue Dec 18 19:10:17 2012
@@ -65,11 +65,11 @@
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 @@
bool isInt() const { return !IsFp; }
private:
+
bool IsFp;
// True iff FpValBuf contains an instance of APFloat.
@@ -88,11 +89,8 @@
// 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
More information about the llvm-commits
mailing list