87 lines · plain
1# RUN: split-file %s %t2# RUN: llvm-mc -triple=wasm32-unknown-unknown -filetype=obj %t/ok.s | llvm-readobj --symbols - | FileCheck %s3# RUN: llvm-mc -triple=wasm32-unknown-unknown -filetype=obj %t/ok.s | obj2yaml | FileCheck --check-prefix=YAML %s4# RUN: not llvm-mc -triple=wasm32-unknown-unknown -filetype=obj %t/conflict.s 2>&1 | FileCheck --check-prefix=ERR %s5# RUN: not llvm-mc -triple=wasm32-unknown-unknown -filetype=obj %t/conflict-sym.s 2>&1 | FileCheck --check-prefix=ERRSYM %s6 7# Regression test for a wasm duplicate-definition error on a repeated8# absolute-constant assembler symbol assignment ("X = N" / ".set X, N").9#10# A bare absolute-constant assignment is lowered to a *defined data object*11# holding the constant (MCWasmStreamer::emitAssignment, 751ce8312), so the12# symbol becomes a plain defined label rather than a redefinable variable. A13# second, identical assignment then reached the parser's generic redefinition14# check (the symbol is now defined and not redefinable) and failed with:15# error: redefinition of 'X'16#17# This fires en masse at the glibc whole-program bitcode merge (HWJS-B-1):18# glibc's locale TUs each emit _NL_CURRENT_DEFINE link markers19# (_nl_current_LC_*_used = 2, x12 LC_* per locale TU) via module-level asm, and20# llvm-link concatenates the per-TU module-asm without dedup, so the merged21# module carries several identical "_nl_current_LC_*_used = 2" definitions.22#23# Match GNU-as, where "=" / ".set" is freely reassignable and an identical24# reassignment is a no-op: an identical repeat is accepted (idempotent: one data25# object holding the constant), but a repeat to a *different* value -- or to a26# symbol -- is a genuine conflict and is still rejected loudly. This mirrors the27# alias-form idempotence (66319942b) for the absolute-constant data-object form.28 29#--- ok.s30# An identical "=" repeat and an identical ".set" repeat are both accepted; each31# marker resolves to a single defined DATA object holding the constant (no32# duplicate, no error).33 .globl marker_used34marker_used = 235 .globl marker_used36marker_used = 237 38 .globl set_marker39 .set set_marker, 540 .set set_marker, 541 42 .globl f43f:44 .functype f () -> ()45 end_function46 47# CHECK: Symbols [48# CHECK: Name: marker_used49# CHECK-NEXT: Type: DATA50# CHECK: Size: 0x451# CHECK: Name: set_marker52# CHECK-NEXT: Type: DATA53# CHECK: Size: 0x454# CHECK: Name: f55# CHECK-NEXT: Type: FUNCTION56# CHECK: ]57 58# The constant is stored once, little-endian (value preserved): one segment per59# marker, marker_used == 2 and set_marker == 5.60# YAML: Content: '02000000'61# YAML: Content: '05000000'62# YAML: Name: .data.marker_used63# YAML: Name: .data.set_marker64 65#--- conflict.s66# A repeat to a *different* constant is a genuine conflict: never-silent, it is67# rejected loudly rather than silently picking one value.68 .globl marker_used69marker_used = 270marker_used = 371 72# ERR: error: conflicting redefinition of 'marker_used'73 74#--- conflict-sym.s75# A repeat that retargets the absolute-constant marker to a *symbol* is likewise76# a genuine conflict and is rejected loudly.77 .globl g78g:79 .functype g () -> ()80 end_function81 82 .globl marker_used83marker_used = 284marker_used = g85 86# ERRSYM: error: conflicting redefinition of 'marker_used'87