[llvm] r257111 - WebAssembly: use .skip instead of .zero directive

JF Bastien via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 7 15:18:29 PST 2016


Author: jfb
Date: Thu Jan  7 17:18:29 2016
New Revision: 257111

URL: http://llvm.org/viewvc/llvm-project?rev=257111&view=rev
Log:
WebAssembly: use .skip instead of .zero directive

.zero is confusing when used with two arguments. Documentation:

  This directive emits SIZE 0-valued bytes.  SIZE must be an absolute
  expression.  This directive is actually an alias for the '.skip'
  directive so in can take an optional second argument of the value to
  store in the bytes instead of zero.  Using '.zero' in this way would be
  confusing however.

Ref: https://sourceware.org/bugzilla/show_bug.cgi?id=18353

Hexagon and Sparc do the same, and it's all the same to WebAssembly so
let's pick the less confusing of the two.

Modified:
    llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCAsmInfo.cpp
    llvm/trunk/test/CodeGen/WebAssembly/global.ll

Modified: llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCAsmInfo.cpp?rev=257111&r1=257110&r2=257111&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCAsmInfo.cpp Thu Jan  7 17:18:29 2016
@@ -29,6 +29,10 @@ WebAssemblyMCAsmInfo::WebAssemblyMCAsmIn
 
   UseDataRegionDirectives = true;
 
+  // Use .skip instead of .zero because .zero is confusing when used with two
+  // arguments (it doesn't actually zero things out).
+  ZeroDirective = "\t.skip\t";
+
   Data8bitsDirective = "\t.int8\t";
   Data16bitsDirective = "\t.int16\t";
   Data32bitsDirective = "\t.int32\t";

Modified: llvm/trunk/test/CodeGen/WebAssembly/global.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WebAssembly/global.ll?rev=257111&r1=257110&r2=257111&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/global.ll (original)
+++ llvm/trunk/test/CodeGen/WebAssembly/global.ll Thu Jan  7 17:18:29 2016
@@ -37,7 +37,7 @@ define i8* @call_memcpy(i8* %p, i8* noca
 @g = private global i32 1337
 
 ; CHECK-LABEL: ud:
-; CHECK-NEXT: .zero 4{{$}}
+; CHECK-NEXT: .skip 4{{$}}
 ; CHECK-NEXT: .size ud, 4{{$}}
 @ud = internal global i32 undef
 
@@ -73,7 +73,7 @@ define i8* @call_memcpy(i8* %p, i8* noca
 ; CHECK: .type ud64, at object
 ; CHECK: .align 3{{$}}
 ; CHECK-NEXT: ud64:
-; CHECK-NEXT: .zero 8{{$}}
+; CHECK-NEXT: .skip 8{{$}}
 ; CHECK-NEXT: .size ud64, 8{{$}}
 @ud64 = internal global i64 undef
 
@@ -102,7 +102,7 @@ define i8* @call_memcpy(i8* %p, i8* noca
 ; CHECK: .type f32ud, at object
 ; CHECK: .align 2{{$}}
 ; CHECK-NEXT: f32ud:
-; CHECK-NEXT: .zero 4{{$}}
+; CHECK-NEXT: .skip 4{{$}}
 ; CHECK-NEXT: .size f32ud, 4{{$}}
 @f32ud = internal global float undef
 
@@ -131,7 +131,7 @@ define i8* @call_memcpy(i8* %p, i8* noca
 ; CHECK: .type f64ud, at object
 ; CHECK: .align 3{{$}}
 ; CHECK-NEXT: f64ud:
-; CHECK-NEXT: .zero 8{{$}}
+; CHECK-NEXT: .skip 8{{$}}
 ; CHECK-NEXT: .size f64ud, 8{{$}}
 @f64ud = internal global double undef
 
@@ -172,6 +172,6 @@ define i8* @call_memcpy(i8* %p, i8* noca
 ; CHECK: .globl   rom{{$}}
 ; CHECK: .align   4{{$}}
 ; CHECK: rom:
-; CHECK: .zero    512{{$}}
+; CHECK: .skip    512{{$}}
 ; CHECK: .size    rom, 512{{$}}
 @rom = constant [128 x i32] zeroinitializer, align 16




More information about the llvm-commits mailing list