[llvm-commits] CVS: gcc-3.4/gcc/llvm-expand.c

Chris Lattner lattner at cs.uiuc.edu
Fri Feb 13 16:14:01 PST 2004


Changes in directory gcc-3.4/gcc:

llvm-expand.c updated: 1.9 -> 1.10

---
Log message:

Fix: test/Regression/CFrontend/2004-02-13-IllegalVararg.c.tr


---
Diffs of the changes:  (+17 -2)

Index: gcc-3.4/gcc/llvm-expand.c
diff -u gcc-3.4/gcc/llvm-expand.c:1.9 gcc-3.4/gcc/llvm-expand.c:1.10
--- gcc-3.4/gcc/llvm-expand.c:1.9	Thu Feb 12 15:04:48 2004
+++ gcc-3.4/gcc/llvm-expand.c	Fri Feb 13 16:12:53 2004
@@ -241,9 +241,24 @@
                                           llvm_type *ArgTy) {
   llvm_value *VAList = append_inst(Fn, create_load_inst("valist", VAListPtr,0));
   llvm_value *Result;
-  llvm_instruction *VA = llvm_instruction_new(ArgTy, "tmp", O_VAArg, 1);
+  llvm_instruction *VA;
+  llvm_type *ActualTy = ArgTy;
 
+  /* Make sure to promote types as needed, even though it's illegal to
+   * va_arg(float).  Since we decimate structures, we might have a float value
+   * being passed through as vararg.
+   */
   assert(llvm_type_is_scalar(ArgTy) && "Not a scalar type?");
+  switch (ActualTy->ID) {
+  case FloatTyID: ActualTy = DoubleTy; break;
+  case SByteTyID: ActualTy = IntTy; break;
+  case ShortTyID: ActualTy = IntTy; break;
+  case UByteTyID: ActualTy = UIntTy; break;
+  case UShortTyID: ActualTy = UIntTy; break;
+  default: break;
+  }
+
+  VA = llvm_instruction_new(ActualTy, "tmp", O_VAArg, 1);
 
   VA->Operands[0] = VAList;
   Result = append_inst(Fn, VA);
@@ -251,7 +266,7 @@
   /* Update the valist */
   VA = llvm_instruction_new(VAList->Ty, "vanextlist", O_VANext, 1);
   VA->Operands[0] = VAList;
-  VA->x.VANext.ArgTy = ArgTy;
+  VA->x.VANext.ArgTy = ActualTy;
   VAList = append_inst(Fn, VA);
   
   append_inst(Fn, create_store_inst(VAList, VAListPtr, 0));





More information about the llvm-commits mailing list