[cfe-commits] r136438 - in /cfe/trunk: lib/CodeGen/CGStmt.cpp test/CodeGen/asm.c

Peter Collingbourne peter at pcc.me.uk
Thu Jul 28 17:24:50 PDT 2011


Author: pcc
Date: Thu Jul 28 19:24:50 2011
New Revision: 136438

URL: http://llvm.org/viewvc/llvm-project?rev=136438&view=rev
Log:
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.

Modified:
    cfe/trunk/lib/CodeGen/CGStmt.cpp
    cfe/trunk/test/CodeGen/asm.c

Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=136438&r1=136437&r2=136438&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Thu Jul 28 19:24:50 2011
@@ -1533,8 +1533,12 @@
         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 = 

Modified: cfe/trunk/test/CodeGen/asm.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/asm.c?rev=136438&r1=136437&r2=136438&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/asm.c (original)
+++ cfe/trunk/test/CodeGen/asm.c Thu Jul 28 19:24:50 2011
@@ -200,6 +200,15 @@
   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)





More information about the cfe-commits mailing list