aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-04-24 04:55:02 +0000
committerDan Gohman <gohman@apple.com>2010-04-24 04:55:02 +0000
commit2dca88fc6d3e606a8131712be1800e3a4b90ca3e (patch)
treeba7cac770f900a3d9060d8b400f46a61c366b732
parent76d326448d7e4c10b2896edc2ee855d1e68d1b88 (diff)
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
-rw-r--r--lib/CodeGen/CGStmt.cpp11
1 files changed, 8 insertions, 3 deletions
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<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);
}
}