[cfe-commits] r102238 - /cfe/trunk/lib/CodeGen/CGStmt.cpp

Dan Gohman gohman at apple.com
Fri Apr 23 21:55:02 PDT 2010


Author: djg
Date: Fri Apr 23 23:55:02 2010
New Revision: 102238

URL: http://llvm.org/viewvc/llvm-project?rev=102238&view=rev
Log:
Fix a place in inline asm lowering which was creating a TruncInst with a
pointer operand. This fixes an abort on
MultiSource/Applications/ClamAV/libclamav_mbox.c.

Modified:
    cfe/trunk/lib/CodeGen/CGStmt.cpp

Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=102238&r1=102237&r2=102238&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Fri Apr 23 23:55:02 2010
@@ -1141,13 +1141,18 @@
       // a pointer.
       if (TruncTy->isFloatingPointTy())
         Tmp = Builder.CreateFPTrunc(Tmp, TruncTy);
-      else if (!isa<llvm::PointerType>(TruncTy))
-        Tmp = Builder.CreateTrunc(Tmp, TruncTy);
-      else {
+      else if (TruncTy->isPointerTy() && Tmp->getType()->isIntegerTy()) {
         uint64_t ResSize = CGM.getTargetData().getTypeSizeInBits(TruncTy);
         Tmp = Builder.CreateTrunc(Tmp, llvm::IntegerType::get(VMContext,
                                                             (unsigned)ResSize));
         Tmp = Builder.CreateIntToPtr(Tmp, TruncTy);
+      } else if (Tmp->getType()->isPointerTy() && TruncTy->isIntegerTy()) {
+        uint64_t TmpSize =CGM.getTargetData().getTypeSizeInBits(Tmp->getType());
+        Tmp = Builder.CreatePtrToInt(Tmp, llvm::IntegerType::get(VMContext,
+                                                            (unsigned)TmpSize));
+        Tmp = Builder.CreateTrunc(Tmp, TruncTy);
+      } else if (TruncTy->isIntegerTy()) {
+        Tmp = Builder.CreateTrunc(Tmp, TruncTy);
       }
     }
 





More information about the cfe-commits mailing list