Index: include/llvm/MC/MCExpr.h =================================================================== --- include/llvm/MC/MCExpr.h +++ include/llvm/MC/MCExpr.h @@ -279,6 +279,7 @@ VK_Hexagon_IE_GOT, VK_WebAssembly_FUNCTION, // Function table index, rather than virtual addr + VK_WebAssembly_GLOBAL, // Global object index VK_WebAssembly_TYPEINDEX,// Type table index VK_AMDGPU_GOTPCREL32_LO, // symbol@gotpcrel32@lo Index: lib/MC/MCExpr.cpp =================================================================== --- lib/MC/MCExpr.cpp +++ lib/MC/MCExpr.cpp @@ -293,6 +293,7 @@ case VK_Hexagon_IE: return "IE"; case VK_Hexagon_IE_GOT: return "IEGOT"; case VK_WebAssembly_FUNCTION: return "FUNCTION"; + case VK_WebAssembly_GLOBAL: return "GLOBAL"; case VK_WebAssembly_TYPEINDEX: return "TYPEINDEX"; case VK_AMDGPU_GOTPCREL32_LO: return "gotpcrel32@lo"; case VK_AMDGPU_GOTPCREL32_HI: return "gotpcrel32@hi"; Index: lib/MC/MCWasmStreamer.cpp =================================================================== --- lib/MC/MCWasmStreamer.cpp +++ lib/MC/MCWasmStreamer.cpp @@ -117,7 +117,6 @@ break; case MCSA_ELF_TypeObject: - Symbol->setType(wasm::WASM_SYMBOL_TYPE_DATA); break; default: Index: lib/Target/WebAssembly/MCTargetDesc/WebAssemblyFixupKinds.h =================================================================== --- lib/Target/WebAssembly/MCTargetDesc/WebAssemblyFixupKinds.h +++ lib/Target/WebAssembly/MCTargetDesc/WebAssemblyFixupKinds.h @@ -19,8 +19,6 @@ fixup_code_sleb128_i64, // 64-bit signed fixup_code_uleb128_i32, // 32-bit unsigned - fixup_code_global_index, // 32-bit unsigned - // Marker LastTargetFixupKind, NumTargetFixupKinds = LastTargetFixupKind - FirstTargetFixupKind Index: lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp =================================================================== --- lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp +++ lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp @@ -132,7 +132,7 @@ Info.OperandType == WebAssembly::OPERAND_TYPEINDEX) { FixupKind = MCFixupKind(WebAssembly::fixup_code_uleb128_i32); } else if (Info.OperandType == WebAssembly::OPERAND_GLOBAL) { - FixupKind = MCFixupKind(WebAssembly::fixup_code_global_index); + FixupKind = MCFixupKind(WebAssembly::fixup_code_uleb128_i32); } else { llvm_unreachable("unexpected symbolic operand kind"); } Index: lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h =================================================================== --- lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h +++ lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h @@ -86,6 +86,16 @@ // whether the value represents a control-flow label. VariableOpImmediateIsLabel = (1 << 1) }; + +// WebAssembly-specific MachineOperand target flags. +enum WebAssemblyMOTargetFlagVal { + MO_NO_FLAG = 0, + + // Flags to indicate the type of the symbol being referenced + MO_SYMBOL_FUNCTION = 0x1, + MO_SYMBOL_GLOBAL = 0x2, + MO_SYMBOL_MASK = 0x3, +}; } // end namespace WebAssemblyII } // end namespace llvm Index: lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp =================================================================== --- lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp +++ lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp @@ -61,6 +61,11 @@ return RefA && RefA->getKind() == MCSymbolRefExpr::VK_WebAssembly_TYPEINDEX; } +static bool IsGlobalType(const MCValue &Target) { + const MCSymbolRefExpr *RefA = Target.getSymA(); + return RefA && RefA->getKind() == MCSymbolRefExpr::VK_WebAssembly_GLOBAL; +} + unsigned WebAssemblyWasmObjectWriter::getRelocType(const MCValue &Target, const MCFixup &Fixup) const { @@ -69,8 +74,6 @@ bool IsFunction = IsFunctionExpr(Fixup.getValue()); switch (unsigned(Fixup.getKind())) { - case WebAssembly::fixup_code_global_index: - return wasm::R_WEBASSEMBLY_GLOBAL_INDEX_LEB; case WebAssembly::fixup_code_sleb128_i32: if (IsFunction) return wasm::R_WEBASSEMBLY_TABLE_INDEX_SLEB; @@ -78,6 +81,8 @@ case WebAssembly::fixup_code_sleb128_i64: llvm_unreachable("fixup_sleb128_i64 not implemented yet"); case WebAssembly::fixup_code_uleb128_i32: + if (IsGlobalType(Target)) + return wasm::R_WEBASSEMBLY_GLOBAL_INDEX_LEB; if (IsFunctionType(Target)) return wasm::R_WEBASSEMBLY_TYPE_INDEX_LEB; if (IsFunction) Index: lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp +++ lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp @@ -126,7 +126,7 @@ .addMemOperand(MMO); } else { BuildMI(MBB, InsertStore, DL, TII->get(WebAssembly::SET_GLOBAL_I32)) - .addExternalSymbol(SPSymbol) + .addExternalSymbol(SPSymbol, WebAssemblyII::MO_SYMBOL_GLOBAL) .addReg(SrcReg); } } @@ -189,7 +189,7 @@ .addMemOperand(LoadMMO); } else { BuildMI(MBB, InsertPt, DL, TII->get(WebAssembly::GET_GLOBAL_I32), SPReg) - .addExternalSymbol(SPSymbol); + .addExternalSymbol(SPSymbol, WebAssemblyII::MO_SYMBOL_GLOBAL); } bool HasBP = hasBP(MF); Index: lib/Target/WebAssembly/WebAssemblyISelLowering.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyISelLowering.cpp +++ lib/Target/WebAssembly/WebAssemblyISelLowering.cpp @@ -816,7 +816,7 @@ // functions. return DAG.getNode(WebAssemblyISD::Wrapper, DL, VT, DAG.getTargetExternalSymbol(ES->getSymbol(), VT, - /*TargetFlags=*/0x1)); + WebAssemblyII::MO_SYMBOL_FUNCTION)); } SDValue WebAssemblyTargetLowering::LowerJumpTable(SDValue Op, Index: lib/Target/WebAssembly/WebAssemblyMCInstLower.h =================================================================== --- lib/Target/WebAssembly/WebAssemblyMCInstLower.h +++ lib/Target/WebAssembly/WebAssemblyMCInstLower.h @@ -34,7 +34,7 @@ MCSymbol *GetGlobalAddressSymbol(const MachineOperand &MO) const; MCSymbol *GetExternalSymbolSymbol(const MachineOperand &MO) const; MCOperand LowerSymbolOperand(MCSymbol *Sym, int64_t Offset, - bool IsFunc) const; + bool IsFunc, bool IsGlob) const; public: WebAssemblyMCInstLower(MCContext &ctx, WebAssemblyAsmPrinter &printer) Index: lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp +++ lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp @@ -116,9 +116,11 @@ MCOperand WebAssemblyMCInstLower::LowerSymbolOperand(MCSymbol *Sym, int64_t Offset, - bool IsFunc) const { + bool IsFunc, + bool IsGlob) const { MCSymbolRefExpr::VariantKind VK = - IsFunc ? MCSymbolRefExpr::VK_WebAssembly_FUNCTION + IsFunc ? MCSymbolRefExpr::VK_WebAssembly_FUNCTION : + IsGlob ? MCSymbolRefExpr::VK_WebAssembly_GLOBAL : MCSymbolRefExpr::VK_None; const MCExpr *Expr = MCSymbolRefExpr::create(Sym, VK, Ctx); @@ -126,6 +128,8 @@ if (Offset != 0) { if (IsFunc) report_fatal_error("Function addresses with offsets not supported"); + if (IsGlob) + report_fatal_error("Global indexes with offsets not supported"); Expr = MCBinaryExpr::createAdd(Expr, MCConstantExpr::create(Offset, Ctx), Ctx); } @@ -223,18 +227,20 @@ break; } case MachineOperand::MO_GlobalAddress: - assert(MO.getTargetFlags() == 0 && + assert(MO.getTargetFlags() == WebAssemblyII::MO_NO_FLAG && "WebAssembly does not use target flags on GlobalAddresses"); MCOp = LowerSymbolOperand(GetGlobalAddressSymbol(MO), MO.getOffset(), - MO.getGlobal()->getValueType()->isFunctionTy()); + MO.getGlobal()->getValueType()->isFunctionTy(), + false); break; case MachineOperand::MO_ExternalSymbol: // The target flag indicates whether this is a symbol for a // variable or a function. - assert((MO.getTargetFlags() & -2) == 0 && - "WebAssembly uses only one target flag bit on ExternalSymbols"); + assert((MO.getTargetFlags() & ~WebAssemblyII::MO_SYMBOL_MASK) == 0 && + "WebAssembly uses only symbol flags on ExternalSymbols"); MCOp = LowerSymbolOperand(GetExternalSymbolSymbol(MO), /*Offset=*/0, - MO.getTargetFlags() & 1); + (MO.getTargetFlags() & WebAssemblyII::MO_SYMBOL_FUNCTION) != 0, + (MO.getTargetFlags() & WebAssemblyII::MO_SYMBOL_GLOBAL) != 0); break; } Index: test/CodeGen/WebAssembly/byval.ll =================================================================== --- test/CodeGen/WebAssembly/byval.ll +++ test/CodeGen/WebAssembly/byval.ll @@ -24,12 +24,12 @@ define void @byval_arg(%SmallStruct* %ptr) { ; CHECK: .param i32 ; Subtract 16 from SP (SP is 16-byte aligned) - ; CHECK-NEXT: get_global $push[[L2:.+]]=, __stack_pointer + ; CHECK-NEXT: get_global $push[[L2:.+]]=, __stack_pointer@GLOBAL ; CHECK-NEXT: i32.const $push[[L3:.+]]=, 16 ; CHECK-NEXT: i32.sub $push[[L11:.+]]=, $pop[[L2]], $pop[[L3]] ; Ensure SP is stored back before the call ; CHECK-NEXT: tee_local $push[[L10:.+]]=, $[[SP:.+]]=, $pop[[L11]]{{$}} - ; CHECK-NEXT: set_global __stack_pointer, $pop[[L10]]{{$}} + ; CHECK-NEXT: set_global __stack_pointer@GLOBAL, $pop[[L10]]{{$}} ; Copy the SmallStruct argument to the stack (SP+12, original SP-4) ; CHECK-NEXT: i32.load $push[[L0:.+]]=, 0($0) ; CHECK-NEXT: i32.store 12($[[SP]]), $pop[[L0]] @@ -41,7 +41,7 @@ ; Restore the stack ; CHECK-NEXT: i32.const $push[[L6:.+]]=, 16 ; CHECK-NEXT: i32.add $push[[L8:.+]]=, $[[SP]], $pop[[L6]] - ; CHECK-NEXT: set_global __stack_pointer, $pop[[L8]] + ; CHECK-NEXT: set_global __stack_pointer@GLOBAL, $pop[[L8]] ; CHECK-NEXT: return ret void } @@ -53,7 +53,7 @@ ; CHECK: i32.const $push[[L1:.+]]=, 16 ; CHECK-NEXT: i32.sub $push[[L11:.+]]=, {{.+}}, $pop[[L1]] ; CHECK-NEXT: tee_local $push[[L10:.+]]=, $[[SP:.+]]=, $pop[[L11]]{{$}} - ; CHECK-NEXT: set_global __stack_pointer, $pop[[L10]]{{$}} + ; CHECK-NEXT: set_global __stack_pointer@GLOBAL, $pop[[L10]]{{$}} ; Copy the SmallStruct argument to the stack (SP+8, original SP-8) ; CHECK-NEXT: i32.load $push[[L0:.+]]=, 0($0){{$}} ; CHECK-NEXT: i32.store 8($[[SP]]), $pop[[L0]]{{$}} @@ -72,7 +72,7 @@ ; CHECK: i32.const $push[[L1:.+]]=, 16 ; CHECK-NEXT: i32.sub $push[[L14:.+]]=, {{.+}}, $pop[[L1]] ; CHECK-NEXT: tee_local $push[[L13:.+]]=, $[[SP:.+]]=, $pop[[L14]] - ; CHECK-NEXT: set_global __stack_pointer, $pop[[L13]] + ; CHECK-NEXT: set_global __stack_pointer@GLOBAL, $pop[[L13]] ; Copy the AlignedStruct argument to the stack (SP+0, original SP-16) ; Just check the last load/store pair of the memcpy ; CHECK: i64.load $push[[L4:.+]]=, 0($0) @@ -110,11 +110,11 @@ ; Call memcpy for "big" byvals. ; CHECK-LABEL: big_byval: -; CHECK: get_global $push[[L2:.+]]=, __stack_pointer{{$}} +; CHECK: get_global $push[[L2:.+]]=, __stack_pointer@GLOBAL{{$}} ; CHECK-NEXT: i32.const $push[[L3:.+]]=, 131072 ; CHECK-NEXT: i32.sub $push[[L11:.+]]=, $pop[[L2]], $pop[[L3]] ; CHECK-NEXT: tee_local $push[[L10:.+]]=, $[[SP:.+]]=, $pop[[L11]]{{$}} -; CHECK-NEXT: set_global __stack_pointer, $pop[[L10]]{{$}} +; CHECK-NEXT: set_global __stack_pointer@GLOBAL, $pop[[L10]]{{$}} ; CHECK-NEXT: i32.const $push[[L0:.+]]=, 131072 ; CHECK-NEXT: i32.call $push[[L11:.+]]=, memcpy@FUNCTION, $[[SP]], ${{.+}}, $pop{{.+}} ; CHECK-NEXT: tee_local $push[[L9:.+]]=, $[[SP:.+]]=, $pop[[L11]]{{$}} Index: test/CodeGen/WebAssembly/reg-stackify.ll =================================================================== --- test/CodeGen/WebAssembly/reg-stackify.ll +++ test/CodeGen/WebAssembly/reg-stackify.ll @@ -450,7 +450,7 @@ ; CHECK-LABEL: stackpointer_dependency: ; CHECK: call {{.+}}, stackpointer_callee@FUNCTION, -; CHECK-NEXT: set_global __stack_pointer, +; CHECK-NEXT: set_global __stack_pointer@GLOBAL, declare i32 @stackpointer_callee(i8* readnone, i8* readnone) declare i8* @llvm.frameaddress(i32) define i32 @stackpointer_dependency(i8* readnone) { Index: test/CodeGen/WebAssembly/stack-alignment.ll =================================================================== --- test/CodeGen/WebAssembly/stack-alignment.ll +++ test/CodeGen/WebAssembly/stack-alignment.ll @@ -6,7 +6,7 @@ declare void @somefunc(i32*) ; CHECK-LABEL: underalign: -; CHECK: get_global $push[[L1:.+]]=, __stack_pointer{{$}} +; CHECK: get_global $push[[L1:.+]]=, __stack_pointer@GLOBAL{{$}} ; CHECK-NEXT: i32.const $push[[L2:.+]]=, 16 ; CHECK-NEXT: i32.sub $push[[L10:.+]]=, $pop[[L1]], $pop[[L2]] ; CHECK-NEXT: tee_local $push{{.+}}=, [[SP:.+]], $pop[[L10]] @@ -17,7 +17,7 @@ ; CHECK: get_local $push[[M4:.+]]=, [[SP]]{{$}} ; CHECK: i32.add $push[[L5:.+]]=, $pop[[M4]], $pop{{.+}} -; CHECK-NEXT: set_global __stack_pointer, $pop[[L5]] +; CHECK-NEXT: set_global __stack_pointer@GLOBAL, $pop[[L5]] define void @underalign() { entry: %underaligned = alloca i32, align 8 @@ -26,7 +26,7 @@ } ; CHECK-LABEL: overalign: -; CHECK: get_global $push[[L10:.+]]=, __stack_pointer{{$}} +; CHECK: get_global $push[[L10:.+]]=, __stack_pointer@GLOBAL{{$}} ; CHECK-NEXT: tee_local $push[[L9:.+]]=, [[BP:.+]], $pop[[L10]] ; CHECK-NEXT: i32.const $push[[L2:.+]]=, 32 ; CHECK-NEXT: i32.sub $push[[L8:.+]]=, $pop[[L9]], $pop[[L2]] @@ -38,7 +38,7 @@ ; CHECK: call somefunc@FUNCTION, $pop[[M5]]{{$}} ; CHECK: get_local $push[[M6:.+]]=, [[BP]]{{$}} -; CHECK-NEXT: set_global __stack_pointer, $pop[[M6]] +; CHECK-NEXT: set_global __stack_pointer@GLOBAL, $pop[[M6]] define void @overalign() { entry: %overaligned = alloca i32, align 32 @@ -47,7 +47,7 @@ } ; CHECK-LABEL: over_and_normal_align: -; CHECK: get_global $push[[L14:.+]]=, __stack_pointer{{$}} +; CHECK: get_global $push[[L14:.+]]=, __stack_pointer@GLOBAL{{$}} ; CHECK-NEXT: tee_local $push[[L13:.+]]=, [[BP:.+]], $pop[[L14]] ; CHECK: i32.sub $push[[L12:.+]]=, $pop[[L13]], $pop{{.+}} ; CHECK: i32.and $push[[L11:.+]]=, $pop[[L12]], $pop{{.+}} @@ -61,7 +61,7 @@ ; CHECK-NEXT: call somefunc@FUNCTION, $pop[[L8]] ; CHECK: get_local $push[[L6:.+]]=, [[BP]]{{$}} -; CHECK-NEXT: set_global __stack_pointer, $pop[[L6]] +; CHECK-NEXT: set_global __stack_pointer@GLOBAL, $pop[[L6]] define void @over_and_normal_align() { entry: %over = alloca i32, align 32 @@ -72,7 +72,7 @@ } ; CHECK-LABEL: dynamic_overalign: -; CHECK: get_global $push[[L18:.+]]=, __stack_pointer{{$}} +; CHECK: get_global $push[[L18:.+]]=, __stack_pointer@GLOBAL{{$}} ; CHECK-NEXT: tee_local $push[[L17:.+]]=, [[SP:.+]], $pop[[L18]] ; CHECK-NEXT: set_local [[BP:.+]], $pop[[L17]] ; CHECK: tee_local $push{{.+}}=, [[SP_2:.+]], $pop{{.+}} @@ -81,7 +81,7 @@ ; CHECK: call somefunc@FUNCTION, $pop[[M8]] ; CHECK: get_local $push[[M9:.+]]=, [[BP]]{{$}} -; CHECK-NEXT: set_global __stack_pointer, $pop[[M9]] +; CHECK-NEXT: set_global __stack_pointer@GLOBAL, $pop[[M9]] define void @dynamic_overalign(i32 %num) { entry: %dynamic = alloca i32, i32 %num, align 32 @@ -90,7 +90,7 @@ } ; CHECK-LABEL: overalign_and_dynamic: -; CHECK: get_global $push[[L21:.+]]=, __stack_pointer{{$}} +; CHECK: get_global $push[[L21:.+]]=, __stack_pointer@GLOBAL{{$}} ; CHECK-NEXT: tee_local $push[[L20:.+]]=, [[BP:.+]], $pop[[L21]] ; CHECK: i32.sub $push[[L19:.+]]=, $pop[[L20]], $pop{{.+}} ; CHECK: i32.and $push[[L18:.+]]=, $pop[[L19]], $pop{{.+}} @@ -105,7 +105,7 @@ ; CHECK-NEXT: call somefunc@FUNCTION, $pop[[another]] ; CHECK: get_local $push[[M11:.+]]=, [[BP]]{{$}} -; CHECK-NEXT: set_global __stack_pointer, $pop[[M11]] +; CHECK-NEXT: set_global __stack_pointer@GLOBAL, $pop[[M11]] define void @overalign_and_dynamic(i32 %num) { entry: %over = alloca i32, align 32 @@ -116,7 +116,7 @@ } ; CHECK-LABEL: overalign_static_and_dynamic: -; CHECK: get_global $push[[L26:.+]]=, __stack_pointer{{$}} +; CHECK: get_global $push[[L26:.+]]=, __stack_pointer@GLOBAL{{$}} ; CHECK-NEXT: tee_local $push[[L25:.+]]=, [[BP:.+]], $pop[[L26]] ; CHECK: i32.sub $push[[L24:.+]]=, $pop[[L25]], $pop{{.+}} ; CHECK: i32.and $push[[L23:.+]]=, $pop[[L24]], $pop{{.+}} @@ -136,7 +136,7 @@ ; CHECK-NEXT: call somefunc@FUNCTION, $pop[[static]] ; CHECK: get_local $push[[M14:.+]]=, [[BP]]{{$}} -; CHECK-NEXT: set_global __stack_pointer, $pop[[M14]] +; CHECK-NEXT: set_global __stack_pointer@GLOBAL, $pop[[M14]] define void @overalign_static_and_dynamic(i32 %num) { entry: %over = alloca i32, align 32 Index: test/CodeGen/WebAssembly/userstack.ll =================================================================== --- test/CodeGen/WebAssembly/userstack.ll +++ test/CodeGen/WebAssembly/userstack.ll @@ -10,11 +10,11 @@ ; Check that there is an extra local for the stack pointer. ; CHECK: .local i32{{$}} define void @alloca32() noredzone { - ; CHECK-NEXT: get_global $push[[L2:.+]]=, __stack_pointer{{$}} + ; CHECK-NEXT: get_global $push[[L2:.+]]=, __stack_pointer@GLOBAL{{$}} ; CHECK-NEXT: i32.const $push[[L3:.+]]=, 16 ; CHECK-NEXT: i32.sub $push[[L9:.+]]=, $pop[[L2]], $pop[[L3]] ; CHECK-NEXT: tee_local $push[[L8:.+]]=, [[SP:.+]], $pop[[L9]]{{$}} - ; CHECK-NEXT: set_global __stack_pointer, $pop[[L8]]{{$}} + ; CHECK-NEXT: set_global __stack_pointer@GLOBAL, $pop[[L8]]{{$}} %retval = alloca i32 ; CHECK: get_local $push[[L4:.+]]=, [[SP]]{{$}} ; CHECK: i32.const $push[[L0:.+]]=, 0 @@ -23,14 +23,14 @@ ; CHECK: get_local $push[[L6:.+]]=, [[SP]]{{$}} ; CHECK-NEXT: i32.const $push[[L5:.+]]=, 16 ; CHECK-NEXT: i32.add $push[[L7:.+]]=, $pop[[L6]], $pop[[L5]] - ; CHECK-NEXT: set_global __stack_pointer, $pop[[L7]] + ; CHECK-NEXT: set_global __stack_pointer@GLOBAL, $pop[[L7]] ret void } ; CHECK-LABEL: alloca3264: ; CHECK: .local i32{{$}} define void @alloca3264() { - ; CHECK: get_global $push[[L3:.+]]=, __stack_pointer{{$}} + ; CHECK: get_global $push[[L3:.+]]=, __stack_pointer@GLOBAL{{$}} ; CHECK-NEXT: i32.const $push[[L4:.+]]=, 16 ; CHECK-NEXT: i32.sub $push[[L6:.+]]=, $pop[[L3]], $pop[[L4]] ; CHECK-NEXT: tee_local $push[[L5:.+]]=, [[SP:.+]], $pop[[L6]] @@ -50,11 +50,11 @@ ; CHECK-LABEL: allocarray: ; CHECK: .local i32{{$}} define void @allocarray() { - ; CHECK-NEXT: get_global $push[[L4:.+]]=, __stack_pointer{{$}} + ; CHECK-NEXT: get_global $push[[L4:.+]]=, __stack_pointer@GLOBAL{{$}} ; CHECK-NEXT: i32.const $push[[L5:.+]]=, 144{{$}} ; CHECK-NEXT: i32.sub $push[[L12:.+]]=, $pop[[L4]], $pop[[L5]] ; CHECK-NEXT: tee_local $push[[L11:.+]]=, 0, $pop[[L12]] - ; CHECK-NEXT: set_global __stack_pointer, $pop[[L11]] + ; CHECK-NEXT: set_global __stack_pointer@GLOBAL, $pop[[L11]] %r = alloca [33 x i32] ; CHECK: i32.const $push{{.+}}=, 24 @@ -72,7 +72,7 @@ ; CHECK-NEXT: get_local $push[[L2:.+]]=, [[SP]]{{$}} ; CHECK-NEXT: i32.const $push[[L7:.+]]=, 144 ; CHECK-NEXT: i32.add $push[[L8:.+]]=, $pop[[L2]], $pop[[L7]] - ; CHECK-NEXT: set_global __stack_pointer, $pop[[L8]] + ; CHECK-NEXT: set_global __stack_pointer@GLOBAL, $pop[[L8]] ret void } @@ -81,7 +81,7 @@ ; CHECK: i32.const $push[[L2:.+]]=, 48 ; CHECK-NEXT: i32.sub $push[[L12:.+]]=, {{.+}}, $pop[[L2]] ; CHECK-NEXT: tee_local $push[[L11:.+]]=, [[SP:.+]], $pop[[L12]] - ; CHECK-NEXT: set_global __stack_pointer, $pop[[L11]] + ; CHECK-NEXT: set_global __stack_pointer@GLOBAL, $pop[[L11]] %buf = alloca [27 x i8], align 16 %r = alloca i64 %r2 = alloca i64 @@ -109,11 +109,11 @@ ; CHECK-LABEL: allocarray_inbounds: ; CHECK: .local i32{{$}} define void @allocarray_inbounds() { - ; CHECK: get_global $push[[L3:.+]]=, __stack_pointer{{$}} + ; CHECK: get_global $push[[L3:.+]]=, __stack_pointer@GLOBAL{{$}} ; CHECK-NEXT: i32.const $push[[L4:.+]]=, 32{{$}} ; CHECK-NEXT: i32.sub $push[[L11:.+]]=, $pop[[L3]], $pop[[L4]] ; CHECK-NEXT: tee_local $push[[L10:.+]]=, [[SP:.+]], $pop[[L11]] - ; CHECK-NEXT: set_global __stack_pointer, $pop[[L10]]{{$}} + ; CHECK-NEXT: set_global __stack_pointer@GLOBAL, $pop[[L10]]{{$}} %r = alloca [5 x i32] ; CHECK: i32.const $push[[L3:.+]]=, 1 ; CHECK-DAG: i32.store 24(${{.+}}), $pop[[L3]] @@ -127,29 +127,29 @@ ; CHECK: call ext_func ; CHECK: i32.const $push[[L5:.+]]=, 32{{$}} ; CHECK-NEXT: i32.add $push[[L7:.+]]=, ${{.+}}, $pop[[L5]] - ; CHECK-NEXT: set_global __stack_pointer, $pop[[L7]] + ; CHECK-NEXT: set_global __stack_pointer@GLOBAL, $pop[[L7]] ret void } ; CHECK-LABEL: dynamic_alloca: define void @dynamic_alloca(i32 %alloc) { - ; CHECK: get_global $push[[L13:.+]]=, __stack_pointer{{$}} + ; CHECK: get_global $push[[L13:.+]]=, __stack_pointer@GLOBAL{{$}} ; CHECK-NEXT: tee_local $push[[L12:.+]]=, [[SP:.+]], $pop[[L13]]{{$}} ; Target independent codegen bumps the stack pointer. ; CHECK: i32.sub ; Check that SP is written back to memory after decrement - ; CHECK: set_global __stack_pointer, + ; CHECK: set_global __stack_pointer@GLOBAL, %r = alloca i32, i32 %alloc ; Target-independent codegen also calculates the store addr ; CHECK: call ext_func_i32@FUNCTION call void @ext_func_i32(i32* %r) - ; CHECK: set_global __stack_pointer, $pop{{.+}} + ; CHECK: set_global __stack_pointer@GLOBAL, $pop{{.+}} ret void } ; CHECK-LABEL: dynamic_alloca_redzone: define void @dynamic_alloca_redzone(i32 %alloc) { - ; CHECK: get_global $push[[L13:.+]]=, __stack_pointer{{$}} + ; CHECK: get_global $push[[L13:.+]]=, __stack_pointer@GLOBAL{{$}} ; CHECK-NEXT: tee_local $push[[L12:.+]]=, [[SP:.+]], $pop[[L13]]{{$}} ; Target independent codegen bumps the stack pointer ; CHECK: i32.sub @@ -166,11 +166,11 @@ ; CHECK-LABEL: dynamic_static_alloca: define void @dynamic_static_alloca(i32 %alloc) noredzone { ; Decrement SP in the prolog by the static amount and writeback to memory. - ; CHECK: get_global $push[[L11:.+]]=, __stack_pointer{{$}} + ; CHECK: get_global $push[[L11:.+]]=, __stack_pointer@GLOBAL{{$}} ; CHECK-NEXT: i32.const $push[[L12:.+]]=, 16 ; CHECK-NEXT: i32.sub $push[[L23:.+]]=, $pop[[L11]], $pop[[L12]] ; CHECK-NEXT: tee_local $push[[L22:.+]]=, [[SP:.+]], $pop[[L23]] - ; CHECK-NEXT: set_global __stack_pointer, $pop[[L22]] + ; CHECK-NEXT: set_global __stack_pointer@GLOBAL, $pop[[L22]] ; Alloc and write to a static alloca ; CHECK: get_local $push[[L21:.+]]=, [[SP:.+]] @@ -184,7 +184,7 @@ ; CHECK: i32.sub ; CHECK: tee_local $push[[L16:.+]]=, [[dynamic_local:.+]], $pop{{.+}} ; CHECK: tee_local $push[[L15:.+]]=, [[other:.+]], $pop[[L16]]{{$}} - ; CHECK: set_global __stack_pointer, $pop[[L15]]{{$}} + ; CHECK: set_global __stack_pointer@GLOBAL, $pop[[L15]]{{$}} %dynamic = alloca i32, i32 %alloc ; Ensure we don't modify the frame pointer after assigning it. @@ -226,7 +226,7 @@ ; CHECK: get_local $push[[L24:.+]]=, [[FP]]{{$}} ; CHECK: i32.const $push[[L18:.+]]=, 16 ; CHECK-NEXT: i32.add $push[[L19:.+]]=, $pop[[L24]], $pop[[L18]] - ; CHECK-NEXT: set_global __stack_pointer, $pop[[L19]] + ; CHECK-NEXT: set_global __stack_pointer@GLOBAL, $pop[[L19]] ret void } @@ -235,7 +235,7 @@ ; CHECK-LABEL: llvm_stack_builtins: define void @llvm_stack_builtins(i32 %alloc) noredzone { - ; CHECK: get_global $push[[L11:.+]]=, __stack_pointer{{$}} + ; CHECK: get_global $push[[L11:.+]]=, __stack_pointer@GLOBAL{{$}} ; CHECK-NEXT: tee_local $push[[L10:.+]]=, {{.+}}, $pop[[L11]] ; CHECK-NEXT: set_local [[STACK:.+]], $pop[[L10]] %stack = call i8* @llvm.stacksave() @@ -245,7 +245,7 @@ %dynamic = alloca i32, i32 %alloc ; CHECK: get_local $push[[L12:.+]]=, [[STACK]] - ; CHECK-NEXT: set_global __stack_pointer, $pop[[L12]] + ; CHECK-NEXT: set_global __stack_pointer@GLOBAL, $pop[[L12]] call void @llvm.stackrestore(i8* %stack) ret void @@ -256,7 +256,7 @@ ; moved after the stack pointer was updated for the dynamic alloca. ; CHECK-LABEL: dynamic_alloca_nouse: define void @dynamic_alloca_nouse(i32 %alloc) noredzone { - ; CHECK: get_global $push[[L11:.+]]=, __stack_pointer{{$}} + ; CHECK: get_global $push[[L11:.+]]=, __stack_pointer@GLOBAL{{$}} ; CHECK-NEXT: tee_local $push[[L10:.+]]=, {{.+}}, $pop[[L11]] ; CHECK-NEXT: set_local [[FP:.+]], $pop[[L10]] %dynamic = alloca i32, i32 %alloc @@ -264,7 +264,7 @@ ; CHECK-NOT: set_local [[FP]], ; CHECK: get_local $push[[L12:.+]]=, [[FP]] - ; CHECK-NEXT: set_global __stack_pointer, $pop[[L12]] + ; CHECK-NEXT: set_global __stack_pointer@GLOBAL, $pop[[L12]] ret void } @@ -295,11 +295,11 @@ ; Test __builtin_frame_address(0). ; CHECK-LABEL: frameaddress_0: -; CHECK: get_global $push[[L3:.+]]=, __stack_pointer{{$}} +; CHECK: get_global $push[[L3:.+]]=, __stack_pointer@GLOBAL{{$}} ; CHECK-NEXT: tee_local $push[[L2:.+]]=, [[FP:.+]], $pop[[L3]]{{$}} ; CHECK-NEXT: call use_i8_star@FUNCTION, $pop[[L2]] ; CHECK-NEXT: get_local $push[[L5:.+]]=, [[FP]] -; CHECK-NEXT: set_global __stack_pointer, $pop[[L5]] +; CHECK-NEXT: set_global __stack_pointer@GLOBAL, $pop[[L5]] define void @frameaddress_0() { %t = call i8* @llvm.frameaddress(i32 0) call void @use_i8_star(i8* %t) @@ -320,7 +320,7 @@ ; Test a stack address passed to an inline asm. ; CHECK-LABEL: inline_asm: -; CHECK: get_global {{.+}}, __stack_pointer{{$}} +; CHECK: get_global {{.+}}, __stack_pointer@GLOBAL{{$}} ; CHECK: #APP ; CHECK-NEXT: # %{{[0-9]+}}{{$}} ; CHECK-NEXT: #NO_APP