[llvm-commits] [dragonegg] r129568 - /dragonegg/trunk/src/Convert.cpp

Duncan Sands baldrick at free.fr
Fri Apr 15 07:36:20 PDT 2011


Author: baldrick
Date: Fri Apr 15 09:36:20 2011
New Revision: 129568

URL: http://llvm.org/viewvc/llvm-project?rev=129568&view=rev
Log:
In a MISALIGNED_INDIRECT_REF the alignment need not be a power of two
(but we require a power of two), so replace it with the largest power
of two that divides it.  This should fix PR9711.

Modified:
    dragonegg/trunk/src/Convert.cpp

Modified: dragonegg/trunk/src/Convert.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Convert.cpp?rev=129568&r1=129567&r2=129568&view=diff
==============================================================================
--- dragonegg/trunk/src/Convert.cpp (original)
+++ dragonegg/trunk/src/Convert.cpp Fri Apr 15 09:36:20 2011
@@ -5739,6 +5739,9 @@
 LValue TreeToLLVM::EmitLV_MISALIGNED_INDIRECT_REF(tree exp) {
   // The lvalue is just the address.  The alignment is given by operand 1.
   unsigned Alignment = tree_low_cst(TREE_OPERAND(exp, 1), true);
+  // The alignment need not be a power of two, so replace it with the largest
+  // power of two that divides it.
+  Alignment &= -Alignment;
   if (!Alignment) Alignment = 8;
   assert(!(Alignment & 7) && "Alignment not in octets!");
   LValue LV = LValue(EmitRegister(TREE_OPERAND(exp, 0)), Alignment / 8);





More information about the llvm-commits mailing list