[llvm-commits] CVS: llvm/lib/VMCore/AsmWriter.cpp
Chris Lattner
lattner at cs.uiuc.edu
Mon Jan 3 17:57:09 PST 2005
Changes in directory llvm/lib/VMCore:
AsmWriter.cpp updated: 1.167 -> 1.168
---
Log message:
To not break TBAA rules, use a union.
---
Diffs of the changes: (+9 -5)
Index: llvm/lib/VMCore/AsmWriter.cpp
diff -u llvm/lib/VMCore/AsmWriter.cpp:1.167 llvm/lib/VMCore/AsmWriter.cpp:1.168
--- llvm/lib/VMCore/AsmWriter.cpp:1.167 Thu Dec 9 23:41:10 2004
+++ llvm/lib/VMCore/AsmWriter.cpp Mon Jan 3 19:56:57 2005
@@ -421,7 +421,8 @@
(StrVal[1] >= '0' && StrVal[1] <= '9')))
// Reparse stringized version!
if (atof(StrVal.c_str()) == CFP->getValue()) {
- Out << StrVal; return;
+ Out << StrVal;
+ return;
}
// Otherwise we could not reparse it to exactly the same value, so we must
@@ -430,11 +431,14 @@
// Behave nicely in the face of C TBAA rules... see:
// http://www.nullstone.com/htmls/category/aliastyp.htm
//
- double Val = CFP->getValue();
- char *Ptr = (char*)&Val;
- assert(sizeof(double) == sizeof(uint64_t) && sizeof(double) == 8 &&
+ union {
+ double D;
+ uint64_t U;
+ } V;
+ V.D = CFP->getValue();
+ assert(sizeof(double) == sizeof(uint64_t) &&
"assuming that double is 64 bits!");
- Out << "0x" << utohexstr(*(uint64_t*)Ptr);
+ Out << "0x" << utohexstr(V.U);
} else if (isa<ConstantAggregateZero>(CV)) {
Out << "zeroinitializer";
More information about the llvm-commits
mailing list