This is a clean revision:
The old revision is http://reviews.llvm.org/D13869#inline-115174
This align directive doesn't work on the -fasm-blocks.
ALIGN [[number]]
Aligns the next variable or instruction on a byte that is a multiple of number.
Microsoft support only power of 2 align like gcc and icc .
The problem with the code was in the AsmParser.cpp
Inside the AsmParser::parseDirectiveMSAlign function we trying to lowering number in to log of two. This is not correct and not consistent with Microsoft compilers.
**CASE 1: Microsoft compatibility
align should work only with address of multiply of two.
int f(void) { __asm { align 2 } __asm { align 4 } __asm { align 8 } __asm { align 16 } __asm { align 32 } return 0; } int main() { return f(); }
CASE 2: Darwin compatibility
Incorrect lowering inline asm with -fasm-blocks for Darwin.
int f(void) { asm { align 2 } asm { align 4 } return 0; }
Output
## InlineAsm Start .align 1, 0x90 ## InlineAsm End mov dword ptr [esp], eax ## InlineAsm Start .align 2, 0x90 ## InlineAsm End
It's should be
## InlineAsm Start .align 2, 0x90 ## InlineAsm End mov dword ptr [esp], eax ## InlineAsm Start .align 4, 0x90 ## InlineAsm End
For not log2 number like align 3 error retrieve.