[llvm-commits] [llvm-gcc-4.2] r59719 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp

Tanya Lattner tonic at nondot.org
Wed Nov 19 23:42:32 PST 2008


Author: tbrethou
Date: Thu Nov 20 01:42:31 2008
New Revision: 59719

URL: http://llvm.org/viewvc/llvm-project?rev=59719&view=rev
Log:
Fix indentation.
Cast struct field to i8* before calling intrinsic.

Modified:
    llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp

Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=59719&r1=59718&r2=59719&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Thu Nov 20 01:42:31 2008
@@ -5991,11 +5991,11 @@
 LValue TreeToLLVM::EmitLV_COMPONENT_REF(tree exp) {
   LValue StructAddrLV = EmitLV(TREE_OPERAND(exp, 0));
   tree FieldDecl = TREE_OPERAND(exp, 1);
-
+  
   assert((TREE_CODE(DECL_CONTEXT(FieldDecl)) == RECORD_TYPE ||
           TREE_CODE(DECL_CONTEXT(FieldDecl)) == UNION_TYPE  ||
           TREE_CODE(DECL_CONTEXT(FieldDecl)) == QUAL_UNION_TYPE));
-   
+  
   // Ensure that the struct type has been converted, so that the fielddecls
   // are laid out.  Note that we convert to the context of the Field, not to the
   // type of Operand #0, because GCC doesn't always have the field match up with
@@ -6004,11 +6004,11 @@
   
   assert((!StructAddrLV.isBitfield() || 
           StructAddrLV.BitStart == 0) && "structs cannot be bitfields!");
-
+  
   StructAddrLV.Ptr = BitCastToType(StructAddrLV.Ptr,
                                    PointerType::getUnqual(StructTy));
   const Type *FieldTy = ConvertType(getDeclaredType(FieldDecl));
-
+  
   // BitStart - This is the actual offset of the field from the start of the
   // struct, in bits.  For bitfields this may be on a non-byte boundary.
   unsigned BitStart = getComponentRefOffsetInBits(exp);
@@ -6021,65 +6021,68 @@
     assert(MemberIndex < StructTy->getNumContainedTypes() &&
            "Field Idx out of range!");
     FieldPtr = Builder.CreateStructGEP(StructAddrLV.Ptr, MemberIndex);
-
+    
     // Now that we did an offset from the start of the struct, subtract off
     // the offset from BitStart.
     if (MemberIndex) {
       const StructLayout *SL = TD.getStructLayout(cast<StructType>(StructTy));
       BitStart -= SL->getElementOffset(MemberIndex) * 8;
     }
-      
+    
     // If the FIELD_DECL has an annotate attribute on it, emit it.
-      
+    
     // Handle annotate attribute on global.
     if (tree AnnotateAttr = 
         lookup_attribute("annotate", DECL_ATTRIBUTES(FieldDecl))) {
+      
+      const Type *OrigPtrTy = FieldPtr->getType();
+      const Type *SBP = PointerType::getUnqual(Type::Int8Ty);
+      
+      Function *Fn = Intrinsic::getDeclaration(TheModule, 
+                                               Intrinsic::ptr_annotation,
+                                               &SBP, 1);
+      
+      // Get file and line number.  FIXME: Should this be for the decl or the
+      // use.  Is there a location info for the use?
+      Constant *LineNo = ConstantInt::get(Type::Int32Ty,
+                                          DECL_SOURCE_LINE(FieldDecl));
+      Constant *File = ConvertMetadataStringToGV(DECL_SOURCE_FILE(FieldDecl));
+      
+      File = TheFolder->CreateBitCast(File, SBP);
+      
+      // There may be multiple annotate attributes. Pass return of lookup_attr 
+      //  to successive lookups.
+      while (AnnotateAttr) {
+        // Each annotate attribute is a tree list.
+        // Get value of list which is our linked list of args.
+        tree args = TREE_VALUE(AnnotateAttr);
         
-        const Type *OrigPtrTy = FieldPtr->getType();
-        
-        Function *Fn = Intrinsic::getDeclaration(TheModule, 
-                                                 Intrinsic::ptr_annotation,
-                                                 &OrigPtrTy, 1);
-        
-        // Get file and line number.  FIXME: Should this be for the decl or the
-        // use.  Is there a location info for the use?
-        Constant *LineNo = ConstantInt::get(Type::Int32Ty,
-                                            DECL_SOURCE_LINE(FieldDecl));
-        Constant *File = ConvertMetadataStringToGV(DECL_SOURCE_FILE(FieldDecl));
-        const Type *SBP = PointerType::getUnqual(Type::Int8Ty);
-        File = TheFolder->CreateBitCast(File, SBP);
-        
-        // There may be multiple annotate attributes. Pass return of lookup_attr 
-        //  to successive lookups.
-        while (AnnotateAttr) {
-            // Each annotate attribute is a tree list.
-            // Get value of list which is our linked list of args.
-            tree args = TREE_VALUE(AnnotateAttr);
-            
-            // Each annotate attribute may have multiple args.
-            // Treat each arg as if it were a separate annotate attribute.
-            for (tree a = args; a; a = TREE_CHAIN(a)) {
-                // Each element of the arg list is a tree list, so get value
-                tree val = TREE_VALUE(a);
-                
-                // Assert its a string, and then get that string.
-                assert(TREE_CODE(val) == STRING_CST &&
-                       "Annotate attribute arg should always be a string");
-                
-                const Type *SBP = PointerType::getUnqual(Type::Int8Ty);
-                Constant *strGV = TreeConstantToLLVM::EmitLV_STRING_CST(val);
-                Value *Ops[4] = {
-                    FieldPtr, BitCastToType(strGV, SBP), File,  LineNo
-                };
-                
-                FieldPtr = Builder.CreateCall(Fn, Ops, Ops+4);
-            }
-            
-            // Get next annotate attribute.
-            AnnotateAttr = TREE_CHAIN(AnnotateAttr);
-            if (AnnotateAttr)
-                AnnotateAttr = lookup_attribute("annotate", AnnotateAttr);
+        // Each annotate attribute may have multiple args.
+        // Treat each arg as if it were a separate annotate attribute.
+        for (tree a = args; a; a = TREE_CHAIN(a)) {
+          // Each element of the arg list is a tree list, so get value
+          tree val = TREE_VALUE(a);
+          
+          // Assert its a string, and then get that string.
+          assert(TREE_CODE(val) == STRING_CST &&
+                 "Annotate attribute arg should always be a string");
+          
+          Constant *strGV = TreeConstantToLLVM::EmitLV_STRING_CST(val);
+          Value *Ops[4] = {
+            BitCastToType(FieldPtr, SBP), BitCastToType(strGV, SBP), 
+            File,  LineNo
+          };
+          
+          const Type* FieldPtrType = FieldPtr->getType();
+          FieldPtr = Builder.CreateCall(Fn, Ops, Ops+4);
+          FieldPtr = BitCastToType(FieldPtr, FieldPtrType);
         }
+        
+        // Get next annotate attribute.
+        AnnotateAttr = TREE_CHAIN(AnnotateAttr);
+        if (AnnotateAttr)
+          AnnotateAttr = lookup_attribute("annotate", AnnotateAttr);
+      }
     }      
   } else {
     Value *Offset = Emit(field_offset, 0);





More information about the llvm-commits mailing list