[llvm-commits] [llvm] r55921 - in /llvm/trunk: docs/LangRef.html lib/VMCore/Verifier.cpp

Dan Gohman gohman at apple.com
Mon Sep 8 09:45:59 PDT 2008


Author: djg
Date: Mon Sep  8 11:45:59 2008
New Revision: 55921

URL: http://llvm.org/viewvc/llvm-project?rev=55921&view=rev
Log:
Bitcasting two or from aggregate types is not permitted. Update
LangRef.html, and teach the verifier to check bitcast instructions.

Modified:
    llvm/trunk/docs/LangRef.html
    llvm/trunk/lib/VMCore/Verifier.cpp

Modified: llvm/trunk/docs/LangRef.html
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.html?rev=55921&r1=55920&r2=55921&view=diff

==============================================================================
--- llvm/trunk/docs/LangRef.html (original)
+++ llvm/trunk/docs/LangRef.html Mon Sep  8 11:45:59 2008
@@ -1729,7 +1729,8 @@
   was stored to memory and read back as TYPE. In other words, no bits change 
   with this operator, just the type.  This can be used for conversion of
   vector types to any other type, as long as they have the same bit width. For
-  pointers it is only valid to cast to another pointer type.
+  pointers it is only valid to cast to another pointer type. It is not valid
+  to bitcast to or from an aggregate type.
   </dd>
 
   <dt><b><tt>getelementptr ( CSTPTR, IDX0, IDX1, ... )</tt></b></dt>
@@ -3808,8 +3809,9 @@
 <h5>Arguments:</h5>
 
 <p>The '<tt>bitcast</tt>' instruction takes a value to cast, which must be 
-a first class value, and a type to cast it to, which must also be a <a
-  href="#t_firstclass">first class</a> type. The bit sizes of <tt>value</tt>
+a non-aggregate first class value, and a type to cast it to, which must also be
+a non-aggregate <a href="#t_firstclass">first class</a> type. The bit sizes of
+<tt>value</tt>
 and the destination type, <tt>ty2</tt>, must be identical. If the source
 type is a pointer, the destination type must also be a pointer.  This
 instruction supports bitwise conversion of vectors to integers and to vectors

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

==============================================================================
--- llvm/trunk/lib/VMCore/Verifier.cpp (original)
+++ llvm/trunk/lib/VMCore/Verifier.cpp Mon Sep  8 11:45:59 2008
@@ -883,6 +883,12 @@
           "Bitcast requires both operands to be pointer or neither", &I);
   Assert1(SrcBitSize == DestBitSize, "Bitcast requies types of same width", &I);
 
+  // Disallow aggregates.
+  Assert1(!SrcTy->isAggregateType(),
+          "Bitcast operand must not be aggregate", &I);
+  Assert1(!DestTy->isAggregateType(),
+          "Bitcast type must not be aggregate", &I);
+
   visitInstruction(I);
 }
 





More information about the llvm-commits mailing list