OSDN Git Service

[WebAssembly] MCFixupKindInfo's TargetSize is in bits rather than bytes.
authorDan Gohman <dan433584@gmail.com>
Wed, 13 Jan 2016 19:29:37 +0000 (19:29 +0000)
committerDan Gohman <dan433584@gmail.com>
Wed, 13 Jan 2016 19:29:37 +0000 (19:29 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257655 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/WebAssembly/MCTargetDesc/WebAssemblyAsmBackend.cpp
test/CodeGen/WebAssembly/global.ll

index bba06f6..3269ff0 100644 (file)
@@ -73,8 +73,8 @@ void WebAssemblyAsmBackend::applyFixup(const MCFixup &Fixup, char *Data,
                                        unsigned DataSize, uint64_t Value,
                                        bool IsPCRel) const {
   const MCFixupKindInfo &Info = getFixupKindInfo(Fixup.getKind());
-  unsigned NumBytes = RoundUpToAlignment(Info.TargetSize, 8);
-  if (!Value)
+  unsigned NumBytes = (Info.TargetSize + 7) / 8;
+  if (Value == 0)
     return; // Doesn't change encoding.
 
   // Shift the value into position.
index 85fe5c8..c95d390 100644 (file)
@@ -175,3 +175,17 @@ define i8* @call_memcpy(i8* %p, i8* nocapture readonly %q, i32 %n) {
 ; CHECK: .skip    512{{$}}
 ; CHECK: .size    rom, 512{{$}}
 @rom = constant [128 x i32] zeroinitializer, align 16
+
+; CHECK: .type       array,@object
+; CHECK-NEXT: array:
+; CHECK-NEXT: .skip       8
+; CHECK-NEXT: .size       array, 8
+; CHECK: .type       pointer_to_array,@object
+; CHECK-NEXT: .section    .data.rel.ro,"aw",@progbits
+; CHECK-NEXT: .globl      pointer_to_array
+; CHECK-NEXT: .align      2
+; CHECK-NEXT: pointer_to_array:
+; CHECK-NEXT: .int32      array+4
+; CHECK-NEXT: .size       pointer_to_array, 4
+@array = internal constant [8 x i8] zeroinitializer, align 1
+@pointer_to_array = constant i8* getelementptr inbounds ([8 x i8], [8 x i8]* @array, i32 0, i32 4), align 4