summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2011-07-29 00:24:50 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2011-07-29 00:24:50 +0000
commit05500ba6ecc477b596c64279d7f5f1a353485b16 (patch)
tree1d2eed3798fb81a7e080aa07a651fe0f8936eab9
parent3bc84ca376a29e883d09c03b25127c3993cdf55a (diff)
downloadbcm5719-llvm-05500ba6ecc477b596c64279d7f5f1a353485b16.tar.gz
bcm5719-llvm-05500ba6ecc477b596c64279d7f5f1a353485b16.zip
Fix assertion failure in CodeGen where the input operand to an asm
instruction is tied to an output operand which is a pointer, and the input operand is narrower than the output operand. llvm-svn: 136438
-rw-r--r--clang/lib/CodeGen/CGStmt.cpp6
-rw-r--r--clang/test/CodeGen/asm.c9
2 files changed, 14 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index 60db07d388a..9987fd900b9 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -1533,8 +1533,12 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
llvm::Type *OutputTy = ConvertType(OutputType);
if (isa<llvm::IntegerType>(OutputTy))
Arg = Builder.CreateZExt(Arg, OutputTy);
- else
+ else if (isa<llvm::PointerType>(OutputTy))
+ Arg = Builder.CreateZExt(Arg, IntPtrTy);
+ else {
+ assert(OutputTy->isFloatingPointTy() && "Unexpected output type");
Arg = Builder.CreateFPExt(Arg, OutputTy);
+ }
}
}
if (llvm::Type* AdjTy =
diff --git a/clang/test/CodeGen/asm.c b/clang/test/CodeGen/asm.c
index a2d56c84f46..019eb9ca3e6 100644
--- a/clang/test/CodeGen/asm.c
+++ b/clang/test/CodeGen/asm.c
@@ -200,6 +200,15 @@ unsigned char t23(unsigned char a, unsigned char b) {
return res;
}
+void *t24(char c) {
+ void *addr;
+ // CHECK: @t24
+ // CHECK: zext i8 {{.*}} to i32
+ // CHECK-NEXT: call i8* asm "foobar"
+ __asm__ ("foobar" : "=a" (addr) : "0" (c));
+ return addr;
+}
+
// PR10299 - fpsr, fpcr
void test(void)
OpenPOWER on IntegriCloud