[cfe-commits] r111710 - in /cfe/trunk/lib/CodeGen: CGExpr.cpp CGValue.h

Daniel Dunbar daniel at zuster.org
Fri Aug 20 19:39:23 PDT 2010


Author: ddunbar
Date: Fri Aug 20 21:39:23 2010
New Revision: 111710

URL: http://llvm.org/viewvc/llvm-project?rev=111710&view=rev
Log:
IRgen/CGValue: Add alignment to LValue, and use that alignment when generating lvalue load/stores.

Modified:
    cfe/trunk/lib/CodeGen/CGExpr.cpp
    cfe/trunk/lib/CodeGen/CGValue.h

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=111710&r1=111709&r2=111710&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Fri Aug 20 21:39:23 2010
@@ -635,11 +635,9 @@
     // Simple scalar l-value.
     //
     // FIXME: We shouldn't have to use isSingleValueType here.
-    //
-    // FIXME: Pass alignment!
     if (EltTy->isSingleValueType())
       return RValue::get(EmitLoadOfScalar(Ptr, LV.isVolatileQualified(),
-                                          /*Alignment=*/0, ExprType));
+                                          LV.getAlignment(), ExprType));
 
     assert(ExprType->isFunctionType() && "Unknown scalar value");
     return RValue::get(Ptr);
@@ -849,9 +847,8 @@
   }
 
   assert(Src.isScalar() && "Can't emit an agg store with this method");
-  // FIXME: Pass alignment.
   EmitStoreOfScalar(Src.getScalarVal(), Dst.getAddress(),
-                    Dst.isVolatileQualified(), /*Alignment=*/0, Ty);
+                    Dst.isVolatileQualified(), Dst.getAlignment(), Ty);
 }
 
 void CodeGenFunction::EmitStoreThroughBitfieldLValue(RValue Src, LValue Dst,

Modified: cfe/trunk/lib/CodeGen/CGValue.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGValue.h?rev=111710&r1=111709&r2=111710&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGValue.h (original)
+++ cfe/trunk/lib/CodeGen/CGValue.h Fri Aug 20 21:39:23 2010
@@ -136,6 +136,9 @@
   // 'const' is unused here
   Qualifiers Quals;
 
+  /// The alignment to use when accessing this lvalue.
+  unsigned char Alignment;
+
   // objective-c's ivar
   bool Ivar:1;
   
@@ -154,11 +157,12 @@
 
   Expr *BaseIvarExp;
 private:
-  void Initialize(Qualifiers Quals) {
+  void Initialize(Qualifiers Quals, unsigned Alignment = 0) {
     this->Quals = Quals;
-    
-    // FIXME: Convenient place to set objc flags to 0. This should really be
-    // done in a user-defined constructor instead.
+    this->Alignment = Alignment;
+    assert(this->Alignment == Alignment && "Alignment exceeds allowed max!");
+
+    // Initialize Objective-C flags.
     this->Ivar = this->ObjIsArray = this->NonGC = this->GlobalObjCRef = false;
     this->ThreadLocalRef = false;
     this->BaseIvarExp = 0;
@@ -191,6 +195,8 @@
 
   unsigned getAddressSpace() const { return Quals.getAddressSpace(); }
 
+  unsigned getAlignment() const { return Alignment; }
+
   static void SetObjCIvar(LValue& R, bool iValue) {
     R.Ivar = iValue;
   }
@@ -243,11 +249,12 @@
     return KVCRefExpr;
   }
 
-  static LValue MakeAddr(llvm::Value *V, Qualifiers Quals) {
+  static LValue MakeAddr(llvm::Value *V, Qualifiers Quals,
+                         unsigned Alignment = 0) {
     LValue R;
     R.LVType = Simple;
     R.V = V;
-    R.Initialize(Quals);
+    R.Initialize(Quals, Alignment);
     return R;
   }
 





More information about the cfe-commits mailing list