From 938ff9f0aaed1053886508c5d6e5b25d4b4dfeff Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Wed, 13 Jan 2016 19:29:37 +0000 Subject: [PATCH] [WebAssembly] MCFixupKindInfo's TargetSize is in bits rather than bytes. llvm-svn: 257655 --- .../MCTargetDesc/WebAssemblyAsmBackend.cpp | 4 ++-- llvm/test/CodeGen/WebAssembly/global.ll | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyAsmBackend.cpp b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyAsmBackend.cpp index bba06f65e169..3269ff0da077 100644 --- a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyAsmBackend.cpp +++ b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyAsmBackend.cpp @@ -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. diff --git a/llvm/test/CodeGen/WebAssembly/global.ll b/llvm/test/CodeGen/WebAssembly/global.ll index 85fe5c896565..c95d39055f00 100644 --- a/llvm/test/CodeGen/WebAssembly/global.ll +++ b/llvm/test/CodeGen/WebAssembly/global.ll @@ -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