From: Dan Gohman Date: Sat, 24 Apr 2010 04:55:02 +0000 (+0000) Subject: Fix a place in inline asm lowering which was creating a TruncInst with a X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2dca88fc6d3e606a8131712be1800e3a4b90ca3e;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102238 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp index b90e1c4015..a914c80da2 100644 --- a/lib/CodeGen/CGStmt.cpp +++ b/lib/CodeGen/CGStmt.cpp @@ -1141,13 +1141,18 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) { // a pointer. if (TruncTy->isFloatingPointTy()) Tmp = Builder.CreateFPTrunc(Tmp, TruncTy); - else if (!isa(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); } }