]> granicus.if.org Git - clang/commitdiff
Fix a place in inline asm lowering which was creating a TruncInst with a
authorDan Gohman <gohman@apple.com>
Sat, 24 Apr 2010 04:55:02 +0000 (04:55 +0000)
committerDan Gohman <gohman@apple.com>
Sat, 24 Apr 2010 04:55:02 +0000 (04:55 +0000)
pointer operand. This fixes an abort on
MultiSource/Applications/ClamAV/libclamav_mbox.c.

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

lib/CodeGen/CGStmt.cpp

index b90e1c40158be8bc0334eccb4450124de0f12957..a914c80da2aceec107b45100aad197af8d699816 100644 (file)
@@ -1141,13 +1141,18 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
       // 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);
       }
     }