diff options
author | Chris Lattner <sabre@nondot.org> | 2005-11-05 21:54:03 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-11-05 21:54:03 +0000 |
commit | ac6e5c10db6f3b587c1fe8b2299ee9f7816a8519 (patch) | |
tree | a36423a7695c2e74f14be49bd0736b4e5e106719 | |
parent | 9fad0b9974beb76bef763b8fed71d0c8644403d4 (diff) | |
download | external_llvm-ac6e5c10db6f3b587c1fe8b2299ee9f7816a8519.zip external_llvm-ac6e5c10db6f3b587c1fe8b2299ee9f7816a8519.tar.gz external_llvm-ac6e5c10db6f3b587c1fe8b2299ee9f7816a8519.tar.bz2 |
Verify that alignment amounts are a power of 2
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24198 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/AsmParser/llvmAsmParser.y | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y index c558978..6bfc3bb 100644 --- a/lib/AsmParser/llvmAsmParser.y +++ b/lib/AsmParser/llvmAsmParser.y @@ -2209,6 +2209,9 @@ MemoryInst : MALLOC Types { 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 @@ MemoryInst : MALLOC Types { 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 @@ MemoryInst : MALLOC Types { 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 @@ MemoryInst : MALLOC Types { 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; } |