[PATCH] D13869: instruction 'align' in asm blocks works incorrectly with some cases of parameters

michael zuckerman via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 26 01:17:29 PDT 2015


m_zuckerman updated this revision to Diff 38379.

http://reviews.llvm.org/D13869

Files:
  lib/MC/MCParser/AsmParser.cpp
  test/CodeGen/ms-inline-asm.c

Index: test/CodeGen/ms-inline-asm.c
===================================================================
--- test/CodeGen/ms-inline-asm.c
+++ test/CodeGen/ms-inline-asm.c
@@ -291,13 +291,13 @@
 void t28() {
 // CHECK: t28
   __asm align 8
-// CHECK: .align 3
-  __asm align 16;
-// CHECK: .align 4
-  __asm align 128;
-// CHECK: .align 7
-  __asm ALIGN 256;
 // CHECK: .align 8
+  __asm align 16;
+// CHECK: .align 16
+  __asm align 20;
+// CHECK: .align 20
+  __asm ALIGN 31;
+// CHECK: .align 31
 // CHECK: "~{dirflag},~{fpsr},~{flags}"()
 }
 
Index: lib/MC/MCParser/AsmParser.cpp
===================================================================
--- lib/MC/MCParser/AsmParser.cpp
+++ lib/MC/MCParser/AsmParser.cpp
@@ -4505,12 +4505,12 @@
   const MCConstantExpr *MCE = dyn_cast<MCConstantExpr>(Value);
   if (!MCE)
     return Error(ExprLoc, "unexpected expression in align");
-  uint64_t IntValue = MCE->getValue();
-  if (!isPowerOf2_64(IntValue))
-    return Error(ExprLoc, "literal value not a power of two greater then zero");
-
-  Info.AsmRewrites->push_back(
-      AsmRewrite(AOK_Align, IDLoc, 5, Log2_64(IntValue)));
+  int64_t IntValue = MCE->getValue();
+  if (MAI.getAlignmentIsInBytes()){
+    if (!isPowerOf2_64(IntValue))
+      return Error(ExprLoc, "literal value not a power of two greater then zero");
+  }
+    Info.AsmRewrites->emplace_back(AOK_Align, IDLoc, 5, IntValue);
   return false;
 }
 
@@ -4676,7 +4676,6 @@
       continue;
     }
 
-    unsigned AdditionalSkip = 0;
     // Rewrite expressions in $N notation.
     switch (Kind) {
     default:
@@ -4713,11 +4712,10 @@
       break;
     case AOK_Align: {
       unsigned Val = AR.Val;
-      OS << ".align " << Val;
-
-      // Skip the original immediate.
-      assert(Val < 10 && "Expected alignment less then 2^10.");
-      AdditionalSkip = (Val < 4) ? 2 : Val < 7 ? 3 : 4;
+      OS << ".align";
+      if (!getContext().getAsmInfo()->getAlignmentIsInBytes()){
+        assert(Val < 32 && "Expcted alignment less then 2^32.");
+      }
       break;
     }
     case AOK_DotOperator:
@@ -4730,7 +4728,7 @@
     }
 
     // Skip the original expression.
-    AsmStart = Loc + AR.Len + AdditionalSkip;
+    AsmStart = Loc + AR.Len;
   }
 
   // Emit the remainder of the asm string.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13869.38379.patch
Type: text/x-patch
Size: 2293 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151026/4ba7b4c2/attachment.bin>


More information about the llvm-commits mailing list