]> granicus.if.org Git - clang/commitdiff
Fix assertion failure in CodeGen where the input operand to an asm
authorPeter Collingbourne <peter@pcc.me.uk>
Fri, 29 Jul 2011 00:24:50 +0000 (00:24 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Fri, 29 Jul 2011 00:24:50 +0000 (00:24 +0000)
instruction is tied to an output operand which is a pointer, and
the input operand is narrower than the output operand.

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

lib/CodeGen/CGStmt.cpp
test/CodeGen/asm.c

index 60db07d388ad00a8f1bbad81164a7fe8da2edbc5..9987fd900b97124648c8061cdf5c8af107e4062d 100644 (file)
@@ -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 = 
index a2d56c84f4648d2eac4cf27fba6671ea5bafe1c3..019eb9ca3e6735063277f747351eb1af629359b7 100644 (file)
@@ -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)