summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyAsmBackend.cpp4
-rw-r--r--llvm/test/CodeGen/WebAssembly/global.ll14
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 bba06f65e16..3269ff0da07 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 85fe5c89656..c95d39055f0 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
OpenPOWER on IntegriCloud