Make temporaries explicit to avoid premature
authorDale Johannesen <dalej@apple.com>
Wed, 26 Sep 2007 23:20:33 +0000 (23:20 +0000)
committerDale Johannesen <dalej@apple.com>
Wed, 26 Sep 2007 23:20:33 +0000 (23:20 +0000)
destruction of compiler-created ones.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42383 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Bitcode/Writer/BitcodeWriter.cpp
lib/CodeGen/AsmPrinter.cpp
lib/Target/CBackend/CBackend.cpp
lib/VMCore/AsmWriter.cpp

index fdaa9be5bb615b5b586c463387a32d4759e0502c..7999907c18560b37b6692639a79072438e3d4b92 100644 (file)
@@ -529,11 +529,14 @@ static void WriteConstants(unsigned FirstVal, unsigned LastVal,
       if (Ty == Type::FloatTy || Ty == Type::DoubleTy) {
         Record.push_back(CFP->getValueAPF().convertToAPInt().getZExtValue());
       } else if (Ty == Type::X86_FP80Ty) {
-        const uint64_t *p = CFP->getValueAPF().convertToAPInt().getRawData();
+        // api needed to prevent premature destruction
+        APInt api = CFP->getValueAPF().convertToAPInt();
+        const uint64_t *p = api.getRawData();
         Record.push_back(p[0]);
         Record.push_back((uint16_t)p[1]);
       } else if (Ty == Type::FP128Ty) {
-        const uint64_t *p = CFP->getValueAPF().convertToAPInt().getRawData();
+        APInt api = CFP->getValueAPF().convertToAPInt();
+        const uint64_t *p = api.getRawData();
         Record.push_back(p[0]);
         Record.push_back(p[1]);
       } else if (Ty == Type::PPC_FP128Ty) {
index 521386b19fae859924f081e6e3a0f97c2243243a..88d21af0541ea347c4925998ab2a1be0fffaf27e 100644 (file)
@@ -876,7 +876,9 @@ void AsmPrinter::EmitGlobalConstant(const Constant *CV) {
       return;
     } else if (CFP->getType() == Type::X86_FP80Ty) {
       // all long double variants are printed as hex
-      const uint64_t *p = CFP->getValueAPF().convertToAPInt().getRawData();
+      // api needed to prevent premature destruction
+      APInt api = CFP->getValueAPF().convertToAPInt();
+      const uint64_t *p = api.getRawData();
       if (TD->isBigEndian()) {
         O << TAI->getData16bitsDirective() << uint16_t(p[0] >> 48)
           << "\t" << TAI->getCommentString()
index bc085241d05040eb237e221859087d8794b9a891..6eef297dd663d58f9e39d7ee9c1d4c9cef47ae59 100644 (file)
@@ -1729,7 +1729,9 @@ void CWriter::printFloatingPointConstants(Function &F) {
               << " = 0x" << std::hex << i << std::dec
               << "U;    /* " << Val << " */\n";
         } else if (FPC->getType() == Type::X86_FP80Ty) {
-          const uint64_t *p = FPC->getValueAPF().convertToAPInt().getRawData();
+          // api needed to prevent premature destruction
+          APInt api = FPC->getValueAPF().convertToAPInt();
+          const uint64_t *p = api.getRawData();
           Out << "static const ConstantFP80Ty FPConstant" << FPCounter++
               << " = { 0x" << std::hex
               << ((uint16_t)p[1] | (p[0] & 0xffffffffffffLL)<<16)
index b96fbff88cdb67996a5f357d8f714f9f868d8798..6fb55165be7e70cf8f3aa7792c8e1dc4c67f3a29 100644 (file)
@@ -521,7 +521,9 @@ static void WriteConstantInt(std::ostream &Out, const Constant *CV,
         Out << 'L';
       else
         assert(0 && "Unsupported floating point type");
-      const uint64_t* p = CFP->getValueAPF().convertToAPInt().getRawData();
+      // api needed to prevent premature destruction
+      APInt api = CFP->getValueAPF().convertToAPInt();
+      const uint64_t* p = api.getRawData();
       uint64_t word = *p;
       int shiftcount=60;
       int width = CFP->getValueAPF().convertToAPInt().getBitWidth();