diff options
| author | Shuxin Yang <shuxin.llvm@gmail.com> | 2012-12-19 01:10:17 +0000 |
|---|---|---|
| committer | Shuxin Yang <shuxin.llvm@gmail.com> | 2012-12-19 01:10:17 +0000 |
| commit | 5b841c4a64e338d0d0710422ed6ec5821f6cd43a (patch) | |
| tree | cff77b2aaea8fbac9f7c255efaecf764472b090b | |
| parent | 799d96b8b8865cf96012d9e23e4cfc7558619296 (diff) | |
| download | bcm5719-llvm-5b841c4a64e338d0d0710422ed6ec5821f6cd43a.tar.gz bcm5719-llvm-5b841c4a64e338d0d0710422ed6ec5821f6cd43a.zip | |
Make sure the buffer, which containas an instance of APFloat, has proper alignment.
llvm-svn: 170486
| -rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp index bd642dea36b..30d75343638 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp +++ b/llvm/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 |

