[llvm] r338894 - [WebAssembly] Cleanup of the way globals and global flags are handled
Nicholas Wilson via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 3 07:33:37 PDT 2018
Author: ncw
Date: Fri Aug 3 07:33:37 2018
New Revision: 338894
URL: http://llvm.org/viewvc/llvm-project?rev=338894&view=rev
Log:
[WebAssembly] Cleanup of the way globals and global flags are handled
Differential Revision: https://reviews.llvm.org/D44030
Modified:
llvm/trunk/include/llvm/MC/MCExpr.h
llvm/trunk/lib/MC/MCExpr.cpp
llvm/trunk/lib/MC/MCWasmStreamer.cpp
llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyFixupKinds.h
llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp
llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h
llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp
llvm/trunk/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp
llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
llvm/trunk/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
llvm/trunk/lib/Target/WebAssembly/WebAssemblyMCInstLower.h
llvm/trunk/test/CodeGen/WebAssembly/byval.ll
llvm/trunk/test/CodeGen/WebAssembly/reg-stackify.ll
llvm/trunk/test/CodeGen/WebAssembly/stack-alignment.ll
llvm/trunk/test/CodeGen/WebAssembly/userstack.ll
Modified: llvm/trunk/include/llvm/MC/MCExpr.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCExpr.h?rev=338894&r1=338893&r2=338894&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCExpr.h (original)
+++ llvm/trunk/include/llvm/MC/MCExpr.h Fri Aug 3 07:33:37 2018
@@ -286,6 +286,7 @@ public:
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 at gotpcrel32@lo
Modified: llvm/trunk/lib/MC/MCExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCExpr.cpp?rev=338894&r1=338893&r2=338894&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCExpr.cpp (original)
+++ llvm/trunk/lib/MC/MCExpr.cpp Fri Aug 3 07:33:37 2018
@@ -304,6 +304,7 @@ StringRef MCSymbolRefExpr::getVariantKin
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 at lo";
case VK_AMDGPU_GOTPCREL32_HI: return "gotpcrel32 at hi";
Modified: llvm/trunk/lib/MC/MCWasmStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCWasmStreamer.cpp?rev=338894&r1=338893&r2=338894&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCWasmStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCWasmStreamer.cpp Fri Aug 3 07:33:37 2018
@@ -119,7 +119,6 @@ bool MCWasmStreamer::EmitSymbolAttribute
break;
case MCSA_ELF_TypeObject:
- Symbol->setType(wasm::WASM_SYMBOL_TYPE_DATA);
break;
default:
Modified: llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyFixupKinds.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyFixupKinds.h?rev=338894&r1=338893&r2=338894&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyFixupKinds.h (original)
+++ llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyFixupKinds.h Fri Aug 3 07:33:37 2018
@@ -19,8 +19,6 @@ enum Fixups {
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
Modified: llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp?rev=338894&r1=338893&r2=338894&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp Fri Aug 3 07:33:37 2018
@@ -138,7 +138,7 @@ void WebAssemblyMCCodeEmitter::encodeIns
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");
}
Modified: llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h?rev=338894&r1=338893&r2=338894&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h (original)
+++ llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h Fri Aug 3 07:33:37 2018
@@ -81,6 +81,16 @@ enum {
// whether the value represents a control-flow label.
VariableOpImmediateIsLabel = (1 << 1)
};
+
+/// Target Operand Flag enum.
+enum TOF {
+ 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
Modified: llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp?rev=338894&r1=338893&r2=338894&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp Fri Aug 3 07:33:37 2018
@@ -81,6 +81,11 @@ static const MCSection *GetFixupSection(
return nullptr;
}
+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 {
@@ -89,8 +94,6 @@ WebAssemblyWasmObjectWriter::getRelocTyp
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;
@@ -98,6 +101,8 @@ WebAssemblyWasmObjectWriter::getRelocTyp
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)
Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp?rev=338894&r1=338893&r2=338894&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp Fri Aug 3 07:33:37 2018
@@ -107,7 +107,7 @@ static void writeSPToMemory(unsigned Src
const char *ES = "__stack_pointer";
auto *SPSymbol = MF.createExternalSymbolName(ES);
BuildMI(MBB, InsertStore, DL, TII->get(WebAssembly::SET_GLOBAL_I32))
- .addExternalSymbol(SPSymbol)
+ .addExternalSymbol(SPSymbol, WebAssemblyII::MO_SYMBOL_GLOBAL)
.addReg(SrcReg);
}
@@ -153,7 +153,7 @@ void WebAssemblyFrameLowering::emitProlo
const char *ES = "__stack_pointer";
auto *SPSymbol = MF.createExternalSymbolName(ES);
BuildMI(MBB, InsertPt, DL, TII->get(WebAssembly::GET_GLOBAL_I32), SPReg)
- .addExternalSymbol(SPSymbol);
+ .addExternalSymbol(SPSymbol, WebAssemblyII::MO_SYMBOL_GLOBAL);
bool HasBP = hasBP(MF);
if (HasBP) {
Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp?rev=338894&r1=338893&r2=338894&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp Fri Aug 3 07:33:37 2018
@@ -871,7 +871,7 @@ SDValue WebAssemblyTargetLowering::Lower
// functions.
return DAG.getNode(WebAssemblyISD::Wrapper, DL, VT,
DAG.getTargetExternalSymbol(ES->getSymbol(), VT,
- /*TargetFlags=*/0x1));
+ WebAssemblyII::MO_SYMBOL_FUNCTION));
}
SDValue WebAssemblyTargetLowering::LowerJumpTable(SDValue Op,
Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp?rev=338894&r1=338893&r2=338894&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp Fri Aug 3 07:33:37 2018
@@ -108,9 +108,11 @@ MCSymbol *WebAssemblyMCInstLower::GetExt
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);
@@ -118,6 +120,8 @@ MCOperand WebAssemblyMCInstLower::LowerS
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);
}
@@ -212,18 +216,20 @@ void WebAssemblyMCInstLower::Lower(const
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;
}
Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyMCInstLower.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyMCInstLower.h?rev=338894&r1=338893&r2=338894&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyMCInstLower.h (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyMCInstLower.h Fri Aug 3 07:33:37 2018
@@ -34,7 +34,7 @@ class LLVM_LIBRARY_VISIBILITY WebAssembl
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)
Modified: llvm/trunk/test/CodeGen/WebAssembly/byval.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WebAssembly/byval.ll?rev=338894&r1=338893&r2=338894&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/byval.ll (original)
+++ llvm/trunk/test/CodeGen/WebAssembly/byval.ll Fri Aug 3 07:33:37 2018
@@ -24,12 +24,12 @@ declare void @ext_byval_func_empty(%Empt
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 at 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 at 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 @@ define void @byval_arg(%SmallStruct* %pt
; 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 at GLOBAL, $pop[[L8]]
; CHECK-NEXT: return
ret void
}
@@ -53,7 +53,7 @@ define void @byval_arg_align8(%SmallStru
; 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 at 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 @@ define void @byval_arg_double(%AlignedSt
; 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 at 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 @@ define void @byval_empty_callee(%EmptySt
; Call memcpy for "big" byvals.
; CHECK-LABEL: big_byval:
-; CHECK: get_global $push[[L2:.+]]=, __stack_pointer{{$}}
+; CHECK: get_global $push[[L2:.+]]=, __stack_pointer at 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 at GLOBAL, $pop[[L10]]{{$}}
; CHECK-NEXT: i32.const $push[[L0:.+]]=, 131072
; CHECK-NEXT: i32.call $push[[L11:.+]]=, memcpy at FUNCTION, $[[SP]], ${{.+}}, $pop{{.+}}
; CHECK-NEXT: tee_local $push[[L9:.+]]=, $[[SP:.+]]=, $pop[[L11]]{{$}}
Modified: llvm/trunk/test/CodeGen/WebAssembly/reg-stackify.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WebAssembly/reg-stackify.ll?rev=338894&r1=338893&r2=338894&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/reg-stackify.ll (original)
+++ llvm/trunk/test/CodeGen/WebAssembly/reg-stackify.ll Fri Aug 3 07:33:37 2018
@@ -450,7 +450,7 @@ bb10:
; CHECK-LABEL: stackpointer_dependency:
; CHECK: call {{.+}}, stackpointer_callee at FUNCTION,
-; CHECK-NEXT: set_global __stack_pointer,
+; CHECK-NEXT: set_global __stack_pointer at GLOBAL,
declare i32 @stackpointer_callee(i8* readnone, i8* readnone)
declare i8* @llvm.frameaddress(i32)
define i32 @stackpointer_dependency(i8* readnone) {
Modified: llvm/trunk/test/CodeGen/WebAssembly/stack-alignment.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WebAssembly/stack-alignment.ll?rev=338894&r1=338893&r2=338894&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/stack-alignment.ll (original)
+++ llvm/trunk/test/CodeGen/WebAssembly/stack-alignment.ll Fri Aug 3 07:33:37 2018
@@ -6,7 +6,7 @@ target triple = "wasm32-unknown-unknown"
declare void @somefunc(i32*)
; CHECK-LABEL: underalign:
-; CHECK: get_global $push[[L1:.+]]=, __stack_pointer{{$}}
+; CHECK: get_global $push[[L1:.+]]=, __stack_pointer at 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 @@ declare void @somefunc(i32*)
; 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 at GLOBAL, $pop[[L5]]
define void @underalign() {
entry:
%underaligned = alloca i32, align 8
@@ -26,7 +26,7 @@ entry:
}
; CHECK-LABEL: overalign:
-; CHECK: get_global $push[[L10:.+]]=, __stack_pointer{{$}}
+; CHECK: get_global $push[[L10:.+]]=, __stack_pointer at 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 @@ entry:
; CHECK: call somefunc at FUNCTION, $pop[[M5]]{{$}}
; CHECK: get_local $push[[M6:.+]]=, [[BP]]{{$}}
-; CHECK-NEXT: set_global __stack_pointer, $pop[[M6]]
+; CHECK-NEXT: set_global __stack_pointer at GLOBAL, $pop[[M6]]
define void @overalign() {
entry:
%overaligned = alloca i32, align 32
@@ -47,7 +47,7 @@ entry:
}
; CHECK-LABEL: over_and_normal_align:
-; CHECK: get_global $push[[L14:.+]]=, __stack_pointer{{$}}
+; CHECK: get_global $push[[L14:.+]]=, __stack_pointer at 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 @@ entry:
; CHECK-NEXT: call somefunc at FUNCTION, $pop[[L8]]
; CHECK: get_local $push[[L6:.+]]=, [[BP]]{{$}}
-; CHECK-NEXT: set_global __stack_pointer, $pop[[L6]]
+; CHECK-NEXT: set_global __stack_pointer at GLOBAL, $pop[[L6]]
define void @over_and_normal_align() {
entry:
%over = alloca i32, align 32
@@ -72,7 +72,7 @@ entry:
}
; CHECK-LABEL: dynamic_overalign:
-; CHECK: get_global $push[[L18:.+]]=, __stack_pointer{{$}}
+; CHECK: get_global $push[[L18:.+]]=, __stack_pointer at 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 @@ entry:
; CHECK: call somefunc at FUNCTION, $pop[[M8]]
; CHECK: get_local $push[[M9:.+]]=, [[BP]]{{$}}
-; CHECK-NEXT: set_global __stack_pointer, $pop[[M9]]
+; CHECK-NEXT: set_global __stack_pointer at GLOBAL, $pop[[M9]]
define void @dynamic_overalign(i32 %num) {
entry:
%dynamic = alloca i32, i32 %num, align 32
@@ -90,7 +90,7 @@ entry:
}
; CHECK-LABEL: overalign_and_dynamic:
-; CHECK: get_global $push[[L21:.+]]=, __stack_pointer{{$}}
+; CHECK: get_global $push[[L21:.+]]=, __stack_pointer at 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 @@ entry:
; CHECK-NEXT: call somefunc at FUNCTION, $pop[[another]]
; CHECK: get_local $push[[M11:.+]]=, [[BP]]{{$}}
-; CHECK-NEXT: set_global __stack_pointer, $pop[[M11]]
+; CHECK-NEXT: set_global __stack_pointer at GLOBAL, $pop[[M11]]
define void @overalign_and_dynamic(i32 %num) {
entry:
%over = alloca i32, align 32
@@ -116,7 +116,7 @@ entry:
}
; CHECK-LABEL: overalign_static_and_dynamic:
-; CHECK: get_global $push[[L26:.+]]=, __stack_pointer{{$}}
+; CHECK: get_global $push[[L26:.+]]=, __stack_pointer at 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 @@ entry:
; CHECK-NEXT: call somefunc at FUNCTION, $pop[[static]]
; CHECK: get_local $push[[M14:.+]]=, [[BP]]{{$}}
-; CHECK-NEXT: set_global __stack_pointer, $pop[[M14]]
+; CHECK-NEXT: set_global __stack_pointer at GLOBAL, $pop[[M14]]
define void @overalign_static_and_dynamic(i32 %num) {
entry:
%over = alloca i32, align 32
Modified: llvm/trunk/test/CodeGen/WebAssembly/userstack.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WebAssembly/userstack.ll?rev=338894&r1=338893&r2=338894&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/userstack.ll (original)
+++ llvm/trunk/test/CodeGen/WebAssembly/userstack.ll Fri Aug 3 07:33:37 2018
@@ -10,11 +10,11 @@ declare void @ext_func_i32(i32* %ptr)
; 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 at 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 at GLOBAL, $pop[[L8]]{{$}}
%retval = alloca i32
; CHECK: get_local $push[[L4:.+]]=, [[SP]]{{$}}
; CHECK: i32.const $push[[L0:.+]]=, 0
@@ -23,14 +23,14 @@ define void @alloca32() noredzone {
; 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 at 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 at 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 @@ define void @alloca3264() {
; 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 at 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 at GLOBAL, $pop[[L11]]
%r = alloca [33 x i32]
; CHECK: i32.const $push{{.+}}=, 24
@@ -72,7 +72,7 @@ define void @allocarray() {
; 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 at GLOBAL, $pop[[L8]]
ret void
}
@@ -81,7 +81,7 @@ define void @non_mem_use(i8** %addr) {
; 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 at GLOBAL, $pop[[L11]]
%buf = alloca [27 x i8], align 16
%r = alloca i64
%r2 = alloca i64
@@ -109,11 +109,11 @@ define void @non_mem_use(i8** %addr) {
; 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 at 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 at 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 @@ define void @allocarray_inbounds() {
; 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 at 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 at 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 at GLOBAL,
%r = alloca i32, i32 %alloc
; Target-independent codegen also calculates the store addr
; CHECK: call ext_func_i32 at FUNCTION
call void @ext_func_i32(i32* %r)
- ; CHECK: set_global __stack_pointer, $pop{{.+}}
+ ; CHECK: set_global __stack_pointer at 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 at GLOBAL{{$}}
; CHECK-NEXT: tee_local $push[[L12:.+]]=, [[SP:.+]], $pop[[L13]]{{$}}
; Target independent codegen bumps the stack pointer
; CHECK: i32.sub
@@ -166,11 +166,11 @@ define void @dynamic_alloca_redzone(i32
; 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 at 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 at GLOBAL, $pop[[L22]]
; Alloc and write to a static alloca
; CHECK: get_local $push[[L21:.+]]=, [[SP:.+]]
@@ -184,7 +184,7 @@ define void @dynamic_static_alloca(i32 %
; 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 at GLOBAL, $pop[[L15]]{{$}}
%dynamic = alloca i32, i32 %alloc
; Ensure we don't modify the frame pointer after assigning it.
@@ -226,7 +226,7 @@ define void @dynamic_static_alloca(i32 %
; 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 at GLOBAL, $pop[[L19]]
ret void
}
@@ -235,7 +235,7 @@ declare void @llvm.stackrestore(i8*)
; 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 at 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 @@ define void @llvm_stack_builtins(i32 %al
%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 at GLOBAL, $pop[[L12]]
call void @llvm.stackrestore(i8* %stack)
ret void
@@ -256,7 +256,7 @@ define void @llvm_stack_builtins(i32 %al
; 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 at 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 @@ define void @dynamic_alloca_nouse(i32 %a
; 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 at GLOBAL, $pop[[L12]]
ret void
}
@@ -295,11 +295,11 @@ declare i8* @llvm.frameaddress(i32)
; Test __builtin_frame_address(0).
; CHECK-LABEL: frameaddress_0:
-; CHECK: get_global $push[[L3:.+]]=, __stack_pointer{{$}}
+; CHECK: get_global $push[[L3:.+]]=, __stack_pointer at GLOBAL{{$}}
; CHECK-NEXT: tee_local $push[[L2:.+]]=, [[FP:.+]], $pop[[L3]]{{$}}
; CHECK-NEXT: call use_i8_star at FUNCTION, $pop[[L2]]
; CHECK-NEXT: get_local $push[[L5:.+]]=, [[FP]]
-; CHECK-NEXT: set_global __stack_pointer, $pop[[L5]]
+; CHECK-NEXT: set_global __stack_pointer at 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 @@ define void @frameaddress_1() {
; Test a stack address passed to an inline asm.
; CHECK-LABEL: inline_asm:
-; CHECK: get_global {{.+}}, __stack_pointer{{$}}
+; CHECK: get_global {{.+}}, __stack_pointer at GLOBAL{{$}}
; CHECK: #APP
; CHECK-NEXT: # %{{[0-9]+}}{{$}}
; CHECK-NEXT: #NO_APP
More information about the llvm-commits
mailing list