[llvm-commits] [125417] The address of a VIEW_CONVERT_EXPR is the address of its

dpatel at apple.com dpatel at apple.com
Tue Mar 27 13:12:25 PDT 2007


Revision: 125417
Author:   dpatel
Date:     2007-03-27 13:12:24 -0700 (Tue, 27 Mar 2007)

Log Message:
-----------
The address of a VIEW_CONVERT_EXPR is the address of its
operand, but the type is the type of the expression.  The
current code gets the address right but the type wrong.

Patch by Duncan Sands.

Modified Paths:
--------------
    apple-local/branches/llvm/gcc/llvm-convert.cpp
    apple-local/branches/llvm/gcc/llvm-internal.h

Modified: apple-local/branches/llvm/gcc/llvm-convert.cpp
===================================================================
--- apple-local/branches/llvm/gcc/llvm-convert.cpp	2007-03-27 19:54:13 UTC (rev 125416)
+++ apple-local/branches/llvm/gcc/llvm-convert.cpp	2007-03-27 20:12:24 UTC (rev 125417)
@@ -850,14 +850,17 @@
   case BIT_FIELD_REF: return EmitLV_BIT_FIELD_REF(exp);
   case REALPART_EXPR: return EmitLV_XXXXPART_EXPR(exp, 0);
   case IMAGPART_EXPR: return EmitLV_XXXXPART_EXPR(exp, 1);
+
   // Constants.
   case LABEL_DECL:    return TreeConstantToLLVM::EmitLV_LABEL_DECL(exp);
   case STRING_CST:    return LValue(TreeConstantToLLVM::EmitLV_STRING_CST(exp));
 
+  // Type Conversion.
+  case VIEW_CONVERT_EXPR: return EmitLV_VIEW_CONVERT_EXPR(exp);
+
   // Trivial Cases.
-  case VIEW_CONVERT_EXPR:
   case WITH_SIZE_EXPR:
-    // The address of a these is the address of their operand.
+    // The address is the address of the operand.
     return EmitLV(TREE_OPERAND(exp, 0));
   case INDIRECT_REF:
     // The lvalue is just the address.
@@ -4850,6 +4853,15 @@
                                       "tmp", CurBB));
 }
 
+LValue TreeToLLVM::EmitLV_VIEW_CONVERT_EXPR(tree exp) {
+  // The address is the address of the operand.
+  LValue LV = EmitLV(TREE_OPERAND(exp, 0));
+  // The type is the type of the expression.
+  const Type *Ty = ConvertType(TREE_TYPE(exp));
+  LV.Ptr = BitCastToType(LV.Ptr, PointerType::get(Ty));
+  return LV;
+}
+
 //===----------------------------------------------------------------------===//
 //                       ... Constant Expressions ...
 //===----------------------------------------------------------------------===//

Modified: apple-local/branches/llvm/gcc/llvm-internal.h
===================================================================
--- apple-local/branches/llvm/gcc/llvm-internal.h	2007-03-27 19:54:13 UTC (rev 125416)
+++ apple-local/branches/llvm/gcc/llvm-internal.h	2007-03-27 20:12:24 UTC (rev 125417)
@@ -521,6 +521,7 @@
   LValue EmitLV_COMPONENT_REF(tree_node *exp);
   LValue EmitLV_BIT_FIELD_REF(tree_node *exp);
   LValue EmitLV_XXXXPART_EXPR(tree_node *exp, unsigned Idx);
+  LValue EmitLV_VIEW_CONVERT_EXPR(tree_node *exp);
 
   // Constant Expressions.
   Value *EmitINTEGER_CST(tree_node *exp);





More information about the llvm-commits mailing list