mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 02:33:06 +01:00
[WebAssembly] Add symbol flag to the binary format llvm.used
Summary: Rather than add a new attribute See https://github.com/WebAssembly/tool-conventions/issues/64 Subscribers: dschuff, jgravelle-google, aheejin, sunfish, rupprecht, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D57864 llvm-svn: 353360
This commit is contained in:
parent
5ff99330d2
commit
fc998c1211
@ -289,6 +289,7 @@ const unsigned WASM_SYMBOL_BINDING_LOCAL = 0x2;
|
|||||||
const unsigned WASM_SYMBOL_VISIBILITY_DEFAULT = 0x0;
|
const unsigned WASM_SYMBOL_VISIBILITY_DEFAULT = 0x0;
|
||||||
const unsigned WASM_SYMBOL_VISIBILITY_HIDDEN = 0x4;
|
const unsigned WASM_SYMBOL_VISIBILITY_HIDDEN = 0x4;
|
||||||
const unsigned WASM_SYMBOL_UNDEFINED = 0x10;
|
const unsigned WASM_SYMBOL_UNDEFINED = 0x10;
|
||||||
|
const unsigned WASM_SYMBOL_EXPORTED = 0x20;
|
||||||
|
|
||||||
#define WASM_RELOC(name, value) name = value,
|
#define WASM_RELOC(name, value) name = value,
|
||||||
|
|
||||||
|
@ -46,6 +46,13 @@ public:
|
|||||||
wasm::WasmSymbolType getType() const { return Type; }
|
wasm::WasmSymbolType getType() const { return Type; }
|
||||||
void setType(wasm::WasmSymbolType type) { Type = type; }
|
void setType(wasm::WasmSymbolType type) { Type = type; }
|
||||||
|
|
||||||
|
bool isExported() const {
|
||||||
|
return getFlags() & wasm::WASM_SYMBOL_EXPORTED;
|
||||||
|
}
|
||||||
|
void setExported() const {
|
||||||
|
modifyFlags(wasm::WASM_SYMBOL_EXPORTED, wasm::WASM_SYMBOL_EXPORTED);
|
||||||
|
}
|
||||||
|
|
||||||
bool isWeak() const { return IsWeak; }
|
bool isWeak() const { return IsWeak; }
|
||||||
void setWeak(bool isWeak) { IsWeak = isWeak; }
|
void setWeak(bool isWeak) { IsWeak = isWeak; }
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ void MCAsmInfoWasm::anchor() {}
|
|||||||
|
|
||||||
MCAsmInfoWasm::MCAsmInfoWasm() {
|
MCAsmInfoWasm::MCAsmInfoWasm() {
|
||||||
HasIdentDirective = true;
|
HasIdentDirective = true;
|
||||||
|
HasNoDeadStrip = true;
|
||||||
WeakRefDirective = "\t.weak\t";
|
WeakRefDirective = "\t.weak\t";
|
||||||
PrivateGlobalPrefix = ".L";
|
PrivateGlobalPrefix = ".L";
|
||||||
PrivateLabelPrefix = ".L";
|
PrivateLabelPrefix = ".L";
|
||||||
|
@ -121,6 +121,10 @@ bool MCWasmStreamer::EmitSymbolAttribute(MCSymbol *S, MCSymbolAttr Attribute) {
|
|||||||
case MCSA_Cold:
|
case MCSA_Cold:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MCSA_NoDeadStrip:
|
||||||
|
Symbol->setExported();
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// unrecognized directive
|
// unrecognized directive
|
||||||
llvm_unreachable("unexpected MCSymbolAttr");
|
llvm_unreachable("unexpected MCSymbolAttr");
|
||||||
|
@ -1454,6 +1454,8 @@ uint64_t WasmObjectWriter::writeObject(MCAssembler &Asm,
|
|||||||
Flags |= wasm::WASM_SYMBOL_BINDING_LOCAL;
|
Flags |= wasm::WASM_SYMBOL_BINDING_LOCAL;
|
||||||
if (WS.isUndefined())
|
if (WS.isUndefined())
|
||||||
Flags |= wasm::WASM_SYMBOL_UNDEFINED;
|
Flags |= wasm::WASM_SYMBOL_UNDEFINED;
|
||||||
|
if (WS.isExported())
|
||||||
|
Flags |= wasm::WASM_SYMBOL_EXPORTED;
|
||||||
|
|
||||||
wasm::WasmSymbolInfo Info;
|
wasm::WasmSymbolInfo Info;
|
||||||
Info.Name = WS.getName();
|
Info.Name = WS.getName();
|
||||||
|
@ -486,6 +486,7 @@ void ScalarBitSetTraits<WasmYAML::SymbolFlags>::bitset(
|
|||||||
// BCaseMask(VISIBILITY_MASK, VISIBILITY_DEFAULT);
|
// BCaseMask(VISIBILITY_MASK, VISIBILITY_DEFAULT);
|
||||||
BCaseMask(VISIBILITY_MASK, VISIBILITY_HIDDEN);
|
BCaseMask(VISIBILITY_MASK, VISIBILITY_HIDDEN);
|
||||||
BCaseMask(UNDEFINED, UNDEFINED);
|
BCaseMask(UNDEFINED, UNDEFINED);
|
||||||
|
BCaseMask(EXPORTED, EXPORTED);
|
||||||
#undef BCaseMask
|
#undef BCaseMask
|
||||||
}
|
}
|
||||||
|
|
||||||
|
21
test/MC/WebAssembly/no-dead-strip.ll
Normal file
21
test/MC/WebAssembly/no-dead-strip.ll
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
; RUN: llc -filetype=obj -wasm-keep-registers %s -o - | llvm-readobj --symbols | FileCheck %s
|
||||||
|
|
||||||
|
target triple = "wasm32-unknown-unknown"
|
||||||
|
|
||||||
|
@llvm.used = appending global [1 x i8*] [i8* bitcast (i32 ()* @foo to i8*)], section "llvm.metadata"
|
||||||
|
|
||||||
|
define i32 @foo() {
|
||||||
|
entry:
|
||||||
|
ret i32 0
|
||||||
|
}
|
||||||
|
|
||||||
|
; CHECK: Symbols [
|
||||||
|
; CHECK-NEXT: Symbol {
|
||||||
|
; CHECK-NEXT: Name: foo
|
||||||
|
; CHECK-NEXT: Type: FUNCTION (0x0)
|
||||||
|
; CHECK-NEXT: Flags [ (0x20)
|
||||||
|
; CHECK-NEXT: EXPORTED (0x20)
|
||||||
|
; CHECK-NEXT: ]
|
||||||
|
; CHECK-NEXT: ElementIndex: 0x0
|
||||||
|
; CHECK-NEXT: }
|
||||||
|
; CHECK-NEXT: ]
|
@ -49,6 +49,7 @@ static const EnumEntry<unsigned> WasmSymbolFlags[] = {
|
|||||||
ENUM_ENTRY(VISIBILITY_DEFAULT),
|
ENUM_ENTRY(VISIBILITY_DEFAULT),
|
||||||
ENUM_ENTRY(VISIBILITY_HIDDEN),
|
ENUM_ENTRY(VISIBILITY_HIDDEN),
|
||||||
ENUM_ENTRY(UNDEFINED),
|
ENUM_ENTRY(UNDEFINED),
|
||||||
|
ENUM_ENTRY(EXPORTED),
|
||||||
#undef ENUM_ENTRY
|
#undef ENUM_ENTRY
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user