[llvm-commits] [llvm] r47424 - in /llvm/trunk: lib/VMCore/Value.cpp lib/VMCore/Verifier.cpp test/Assembler/2005-01-31-CallingAggregateFunction.ll test/Assembler/2008-02-20-MultipleReturnValue.ll

Devang Patel dpatel at apple.com
Wed Feb 20 17:54:02 PST 2008


Author: dpatel
Date: Wed Feb 20 19:54:02 2008
New Revision: 47424

URL: http://llvm.org/viewvc/llvm-project?rev=47424&view=rev
Log:
Let function call return aggregate.
Now, we have very first multiple return value testcase!

Added:
    llvm/trunk/test/Assembler/2008-02-20-MultipleReturnValue.ll
Modified:
    llvm/trunk/lib/VMCore/Value.cpp
    llvm/trunk/lib/VMCore/Verifier.cpp
    llvm/trunk/test/Assembler/2005-01-31-CallingAggregateFunction.ll

Modified: llvm/trunk/lib/VMCore/Value.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Value.cpp?rev=47424&r1=47423&r2=47424&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Value.cpp (original)
+++ llvm/trunk/lib/VMCore/Value.cpp Wed Feb 20 19:54:02 2008
@@ -14,6 +14,7 @@
 #include "llvm/Constant.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/InstrTypes.h"
+#include "llvm/Instructions.h"
 #include "llvm/Module.h"
 #include "llvm/ValueSymbolTable.h"
 #include "llvm/Support/Debug.h"
@@ -33,7 +34,11 @@
 Value::Value(const Type *ty, unsigned scid)
   : SubclassID(scid), SubclassData(0), Ty(checkType(ty)),
     UseList(0), Name(0) {
-  if (!isa<Constant>(this) && !isa<BasicBlock>(this))
+  if (isa<CallInst>(this))
+    assert((Ty->isFirstClassType() || Ty == Type::VoidTy ||
+            isa<OpaqueType>(ty) || Ty->getTypeID() == Type::StructTyID) &&
+           "invalid CallInst  type!");
+  else if (!isa<Constant>(this) && !isa<BasicBlock>(this))
     assert((Ty->isFirstClassType() || Ty == Type::VoidTy ||
            isa<OpaqueType>(ty)) &&
            "Cannot create non-first-class values except for constants!");

Modified: llvm/trunk/lib/VMCore/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=47424&r1=47423&r2=47424&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Verifier.cpp (original)
+++ llvm/trunk/lib/VMCore/Verifier.cpp Wed Feb 20 19:54:02 2008
@@ -1071,7 +1071,8 @@
 
   // Check that the return value of the instruction is either void or a legal
   // value type.
-  Assert1(I.getType() == Type::VoidTy || I.getType()->isFirstClassType(),
+  Assert1(I.getType() == Type::VoidTy || I.getType()->isFirstClassType()
+          || (isa<CallInst>(I) && I.getType()->getTypeID() == Type::StructTyID),
           "Instruction returns a non-scalar type!", &I);
 
   // Check that all uses of the instruction, if they are instructions
@@ -1091,11 +1092,24 @@
 
     // Check to make sure that only first-class-values are operands to
     // instructions.
-    Assert1(I.getOperand(i)->getType()->isFirstClassType() 
-            || (isa<ReturnInst>(I) 
-                && I.getOperand(i)->getType()->getTypeID() == Type::StructTyID),
-            "Instruction operands must be first-class values!", &I);
-  
+    if (!I.getOperand(i)->getType()->isFirstClassType()) {
+      if (isa<ReturnInst>(I) || isa<GetResultInst>(I))
+        Assert1(I.getOperand(i)->getType()->getTypeID() == Type::StructTyID,
+                "Invalid ReturnInst operands!", &I);
+      else if (isa<CallInst>(I)) {
+        if (const PointerType *PT = dyn_cast<PointerType>
+            (I.getOperand(i)->getType())) {
+          const Type *ETy = PT->getElementType();
+          Assert1(ETy->getTypeID() == Type::StructTyID,
+                  "Invalid CallInst operands!", &I);
+        }
+        else
+          Assert1(0, "Invalid CallInst operands!", &I);
+      }
+      else
+        Assert1(0, "Instruction operands must be first-class values!", &I);
+    }
+    
     if (Function *F = dyn_cast<Function>(I.getOperand(i))) {
       // Check to make sure that the "address of" an intrinsic function is never
       // taken.

Modified: llvm/trunk/test/Assembler/2005-01-31-CallingAggregateFunction.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/2005-01-31-CallingAggregateFunction.ll?rev=47424&r1=47423&r2=47424&view=diff

==============================================================================
--- llvm/trunk/test/Assembler/2005-01-31-CallingAggregateFunction.ll (original)
+++ llvm/trunk/test/Assembler/2005-01-31-CallingAggregateFunction.ll Wed Feb 20 19:54:02 2008
@@ -1,5 +1,4 @@
 ; RUN: llvm-as < %s -o /dev/null -f 
-; XFAIL: *
 
 define void @test() {
 	call {} @foo()

Added: llvm/trunk/test/Assembler/2008-02-20-MultipleReturnValue.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/2008-02-20-MultipleReturnValue.ll?rev=47424&view=auto

==============================================================================
--- llvm/trunk/test/Assembler/2008-02-20-MultipleReturnValue.ll (added)
+++ llvm/trunk/test/Assembler/2008-02-20-MultipleReturnValue.ll Wed Feb 20 19:54:02 2008
@@ -0,0 +1,12 @@
+; RUN: llvm-as < %s -disable-output
+
+define {i32, i8} @foo(i32 %p) {
+  ret i32 1, i8 2
+}
+
+define i8 @f2(i32 %p) {
+   %c = call {i32, i8} @foo(i32 %p)
+   %d = getresult {i32, i8} %c, 1
+   %e = add i8 %d, 1
+   ret i8 %e
+}





More information about the llvm-commits mailing list