[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y

Chris Lattner lattner at cs.uiuc.edu
Sat Nov 5 13:54:14 PST 2005



Changes in directory llvm/lib/AsmParser:

llvmAsmParser.y updated: 1.233 -> 1.234
---
Log message:

Verify that alignment amounts are a power of 2


---
Diffs of the changes:  (+12 -0)

 llvmAsmParser.y |   12 ++++++++++++
 1 files changed, 12 insertions(+)


Index: llvm/lib/AsmParser/llvmAsmParser.y
diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.233 llvm/lib/AsmParser/llvmAsmParser.y:1.234
--- llvm/lib/AsmParser/llvmAsmParser.y:1.233	Sat Nov  5 03:21:28 2005
+++ llvm/lib/AsmParser/llvmAsmParser.y	Sat Nov  5 15:54:03 2005
@@ -2209,6 +2209,9 @@
     delete $2;
   }
   | MALLOC Types ',' ALIGN EUINT64VAL {
+    if ($5 & ($5-1))
+      ThrowException("Alignment amount '" + utostr($5) +
+                     "' is not a power of 2!");
     $$ = new MallocInst(*$2, 0, $5);
     delete $2;
   }
@@ -2217,6 +2220,9 @@
     delete $2;
   }
   | MALLOC Types ',' UINT ValueRef ',' ALIGN EUINT64VAL {
+    if ($8 & ($8-1))
+      ThrowException("Alignment amount '" + utostr($8) +
+                     "' is not a power of 2!");
     $$ = new MallocInst(*$2, getVal($4, $5), $8);
     delete $2;
   }
@@ -2225,6 +2231,9 @@
     delete $2;
   }
   | ALLOCA Types ',' ALIGN EUINT64VAL {
+    if ($5 & ($5-1))
+      ThrowException("Alignment amount '" + utostr($5) +
+                     "' is not a power of 2!");
     $$ = new AllocaInst(*$2, 0, $5);
     delete $2;
   }
@@ -2233,6 +2242,9 @@
     delete $2;
   }
   | ALLOCA Types ',' UINT ValueRef ',' ALIGN EUINT64VAL {
+    if ($8 & ($8-1))
+      ThrowException("Alignment amount '" + utostr($8) +
+                     "' is not a power of 2!");
     $$ = new AllocaInst(*$2, getVal($4, $5), $8);
     delete $2;
   }






More information about the llvm-commits mailing list