[PATCH] D71493: [WebAssembly] Setting export_name implies no_dead_strip

2019-12-16 Thread Sam Clegg via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0a1e349a7933: [WebAssembly] Setting export_name implies 
llvm.used (authored by sbc100).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71493/new/

https://reviews.llvm.org/D71493

Files:
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/wasm-export-name.c


Index: clang/test/CodeGen/wasm-export-name.c
===
--- clang/test/CodeGen/wasm-export-name.c
+++ clang/test/CodeGen/wasm-export-name.c
@@ -6,6 +6,8 @@
   return 43;
 }
 
+// CHECK: @llvm.used = appending global [1 x i8*] [i8* bitcast (i32 ()* @foo 
to i8*)]
+
 // CHECK: define i32 @foo() [[A:#[0-9]+]]
 
 // CHECK: attributes [[A]] = {{{.*}} "wasm-export-name"="bar" {{.*}}}
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -5772,8 +5772,8 @@
   if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, ))
 return;
 
-  FD->addAttr(::new (S.Context)
-  WebAssemblyExportNameAttr(S.Context, AL, Str));
+  D->addAttr(::new (S.Context) WebAssemblyExportNameAttr(S.Context, AL, Str));
+  D->addAttr(UsedAttr::CreateImplicit(S.Context));
 }
 
 static void handleWebAssemblyImportModuleAttr(Sema , Decl *D, const 
ParsedAttr ) {


Index: clang/test/CodeGen/wasm-export-name.c
===
--- clang/test/CodeGen/wasm-export-name.c
+++ clang/test/CodeGen/wasm-export-name.c
@@ -6,6 +6,8 @@
   return 43;
 }
 
+// CHECK: @llvm.used = appending global [1 x i8*] [i8* bitcast (i32 ()* @foo to i8*)]
+
 // CHECK: define i32 @foo() [[A:#[0-9]+]]
 
 // CHECK: attributes [[A]] = {{{.*}} "wasm-export-name"="bar" {{.*}}}
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -5772,8 +5772,8 @@
   if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, ))
 return;
 
-  FD->addAttr(::new (S.Context)
-  WebAssemblyExportNameAttr(S.Context, AL, Str));
+  D->addAttr(::new (S.Context) WebAssemblyExportNameAttr(S.Context, AL, Str));
+  D->addAttr(UsedAttr::CreateImplicit(S.Context));
 }
 
 static void handleWebAssemblyImportModuleAttr(Sema , Decl *D, const ParsedAttr ) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71493: [WebAssembly] Setting export_name implies no_dead_strip

2019-12-16 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 updated this revision to Diff 234160.
sbc100 added a comment.

- revert part


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71493/new/

https://reviews.llvm.org/D71493

Files:
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/wasm-export-name.c


Index: clang/test/CodeGen/wasm-export-name.c
===
--- clang/test/CodeGen/wasm-export-name.c
+++ clang/test/CodeGen/wasm-export-name.c
@@ -6,6 +6,8 @@
   return 43;
 }
 
+// CHECK: @llvm.used = appending global [1 x i8*] [i8* bitcast (i32 ()* @foo 
to i8*)]
+
 // CHECK: define i32 @foo() [[A:#[0-9]+]]
 
 // CHECK: attributes [[A]] = {{{.*}} "wasm-export-name"="bar" {{.*}}}
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -5772,8 +5772,8 @@
   if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, ))
 return;
 
-  FD->addAttr(::new (S.Context)
-  WebAssemblyExportNameAttr(S.Context, AL, Str));
+  D->addAttr(::new (S.Context) WebAssemblyExportNameAttr(S.Context, AL, Str));
+  D->addAttr(UsedAttr::CreateImplicit(S.Context));
 }
 
 static void handleWebAssemblyImportModuleAttr(Sema , Decl *D, const 
ParsedAttr ) {


Index: clang/test/CodeGen/wasm-export-name.c
===
--- clang/test/CodeGen/wasm-export-name.c
+++ clang/test/CodeGen/wasm-export-name.c
@@ -6,6 +6,8 @@
   return 43;
 }
 
+// CHECK: @llvm.used = appending global [1 x i8*] [i8* bitcast (i32 ()* @foo to i8*)]
+
 // CHECK: define i32 @foo() [[A:#[0-9]+]]
 
 // CHECK: attributes [[A]] = {{{.*}} "wasm-export-name"="bar" {{.*}}}
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -5772,8 +5772,8 @@
   if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, ))
 return;
 
-  FD->addAttr(::new (S.Context)
-  WebAssemblyExportNameAttr(S.Context, AL, Str));
+  D->addAttr(::new (S.Context) WebAssemblyExportNameAttr(S.Context, AL, Str));
+  D->addAttr(UsedAttr::CreateImplicit(S.Context));
 }
 
 static void handleWebAssemblyImportModuleAttr(Sema , Decl *D, const ParsedAttr ) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71493: [WebAssembly] Setting export_name implies no_dead_strip

2019-12-16 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 marked an inline comment as done.
sbc100 added inline comments.



Comment at: llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp:725
   TOut.emitExportName(WasmSym, ExportName);
+  Out.EmitSymbolAttribute(WasmSym, MCSA_NoDeadStrip);
 }

sunfish wrote:
> It feels like this is a little inconsistent. If `export_name` doesn't 
> automatically imply `used` in LLVM IR or .o files, why does it do so in .s 
> files?
OK, reverted that part.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71493/new/

https://reviews.llvm.org/D71493



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71493: [WebAssembly] Setting export_name implies no_dead_strip

2019-12-16 Thread Dan Gohman via Phabricator via cfe-commits
sunfish added inline comments.



Comment at: llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp:725
   TOut.emitExportName(WasmSym, ExportName);
+  Out.EmitSymbolAttribute(WasmSym, MCSA_NoDeadStrip);
 }

It feels like this is a little inconsistent. If `export_name` doesn't 
automatically imply `used` in LLVM IR or .o files, why does it do so in .s 
files?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71493/new/

https://reviews.llvm.org/D71493



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71493: [WebAssembly] Setting export_name implies no_dead_strip

2019-12-16 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 updated this revision to Diff 234144.
sbc100 added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71493/new/

https://reviews.llvm.org/D71493

Files:
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/wasm-export-name.c
  llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
  llvm/test/MC/WebAssembly/export-name.s


Index: llvm/test/MC/WebAssembly/export-name.s
===
--- llvm/test/MC/WebAssembly/export-name.s
+++ llvm/test/MC/WebAssembly/export-name.s
@@ -22,5 +22,5 @@
 # CHECK-OBJ-NEXT:   - Index:   0
 # CHECK-OBJ-NEXT: Kind:FUNCTION
 # CHECK-OBJ-NEXT: Name:foo
-# CHECK-OBJ-NEXT: Flags:   [ EXPORTED ]
+# CHECK-OBJ-NEXT: Flags:   [ EXPORTED, NO_STRIP ]
 # CHECK-OBJ-NEXT: Function:0
Index: llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
===
--- llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
+++ llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
@@ -722,6 +722,7 @@
   auto WasmSym = cast(Ctx.getOrCreateSymbol(SymName));
   WasmSym->setExportName(ExportName);
   TOut.emitExportName(WasmSym, ExportName);
+  Out.EmitSymbolAttribute(WasmSym, MCSA_NoDeadStrip);
 }
 
 if (DirectiveID.getString() == ".import_module") {
Index: clang/test/CodeGen/wasm-export-name.c
===
--- clang/test/CodeGen/wasm-export-name.c
+++ clang/test/CodeGen/wasm-export-name.c
@@ -6,6 +6,8 @@
   return 43;
 }
 
+// CHECK: @llvm.used = appending global [1 x i8*] [i8* bitcast (i32 ()* @foo 
to i8*)]
+
 // CHECK: define i32 @foo() [[A:#[0-9]+]]
 
 // CHECK: attributes [[A]] = {{{.*}} "wasm-export-name"="bar" {{.*}}}
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -5772,8 +5772,8 @@
   if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, ))
 return;
 
-  FD->addAttr(::new (S.Context)
-  WebAssemblyExportNameAttr(S.Context, AL, Str));
+  D->addAttr(::new (S.Context) WebAssemblyExportNameAttr(S.Context, AL, Str));
+  D->addAttr(UsedAttr::CreateImplicit(S.Context));
 }
 
 static void handleWebAssemblyImportModuleAttr(Sema , Decl *D, const 
ParsedAttr ) {


Index: llvm/test/MC/WebAssembly/export-name.s
===
--- llvm/test/MC/WebAssembly/export-name.s
+++ llvm/test/MC/WebAssembly/export-name.s
@@ -22,5 +22,5 @@
 # CHECK-OBJ-NEXT:   - Index:   0
 # CHECK-OBJ-NEXT: Kind:FUNCTION
 # CHECK-OBJ-NEXT: Name:foo
-# CHECK-OBJ-NEXT: Flags:   [ EXPORTED ]
+# CHECK-OBJ-NEXT: Flags:   [ EXPORTED, NO_STRIP ]
 # CHECK-OBJ-NEXT: Function:0
Index: llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
===
--- llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
+++ llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
@@ -722,6 +722,7 @@
   auto WasmSym = cast(Ctx.getOrCreateSymbol(SymName));
   WasmSym->setExportName(ExportName);
   TOut.emitExportName(WasmSym, ExportName);
+  Out.EmitSymbolAttribute(WasmSym, MCSA_NoDeadStrip);
 }
 
 if (DirectiveID.getString() == ".import_module") {
Index: clang/test/CodeGen/wasm-export-name.c
===
--- clang/test/CodeGen/wasm-export-name.c
+++ clang/test/CodeGen/wasm-export-name.c
@@ -6,6 +6,8 @@
   return 43;
 }
 
+// CHECK: @llvm.used = appending global [1 x i8*] [i8* bitcast (i32 ()* @foo to i8*)]
+
 // CHECK: define i32 @foo() [[A:#[0-9]+]]
 
 // CHECK: attributes [[A]] = {{{.*}} "wasm-export-name"="bar" {{.*}}}
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -5772,8 +5772,8 @@
   if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, ))
 return;
 
-  FD->addAttr(::new (S.Context)
-  WebAssemblyExportNameAttr(S.Context, AL, Str));
+  D->addAttr(::new (S.Context) WebAssemblyExportNameAttr(S.Context, AL, Str));
+  D->addAttr(UsedAttr::CreateImplicit(S.Context));
 }
 
 static void handleWebAssemblyImportModuleAttr(Sema , Decl *D, const ParsedAttr ) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71493: [WebAssembly] Setting export_name implies no_dead_strip

2019-12-13 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 created this revision.
Herald added subscribers: llvm-commits, cfe-commits, sunfish, aheejin, 
hiraditya, jgravelle-google, dschuff.
Herald added projects: clang, LLVM.
sbc100 added reviewers: dschuff, sunfish.

This change updates the clang front end to add symbols to llvm.used
when they have explicit export_name attribute.

In also causes the `.export_name` assempler directive to imply the
MCSA_NoDeadStrip symbol attribute.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71493

Files:
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/wasm-export-name.c
  llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
  llvm/test/MC/WebAssembly/export-name.s


Index: llvm/test/MC/WebAssembly/export-name.s
===
--- llvm/test/MC/WebAssembly/export-name.s
+++ llvm/test/MC/WebAssembly/export-name.s
@@ -22,5 +22,5 @@
 # CHECK-OBJ-NEXT:   - Index:   0
 # CHECK-OBJ-NEXT: Kind:FUNCTION
 # CHECK-OBJ-NEXT: Name:foo
-# CHECK-OBJ-NEXT: Flags:   [ EXPORTED ]
+# CHECK-OBJ-NEXT: Flags:   [ EXPORTED, NO_STRIP ]
 # CHECK-OBJ-NEXT: Function:0
Index: llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
===
--- llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
+++ llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
@@ -722,6 +722,7 @@
   auto WasmSym = cast(Ctx.getOrCreateSymbol(SymName));
   WasmSym->setExportName(ExportName);
   TOut.emitExportName(WasmSym, ExportName);
+  Out.EmitSymbolAttribute(WasmSym, MCSA_NoDeadStrip);
 }
 
 if (DirectiveID.getString() == ".import_module") {
Index: clang/test/CodeGen/wasm-export-name.c
===
--- clang/test/CodeGen/wasm-export-name.c
+++ clang/test/CodeGen/wasm-export-name.c
@@ -6,6 +6,8 @@
   return 43;
 }
 
+// CHECK: @llvm.used = appending global [1 x i8*] [i8* bitcast (i32 ()* @foo 
to i8*)]
+
 // CHECK: define i32 @foo() [[A:#[0-9]+]]
 
 // CHECK: attributes [[A]] = {{{.*}} "wasm-export-name"="bar" {{.*}}}
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -5772,8 +5772,8 @@
   if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, ))
 return;
 
-  FD->addAttr(::new (S.Context)
-  WebAssemblyExportNameAttr(S.Context, AL, Str));
+  D->addAttr(::new (S.Context) WebAssemblyExportNameAttr(S.Context, AL, Str));
+  D->addAttr(UsedAttr::CreateImplicit(S.Context));
 }
 
 static void handleWebAssemblyImportModuleAttr(Sema , Decl *D, const 
ParsedAttr ) {


Index: llvm/test/MC/WebAssembly/export-name.s
===
--- llvm/test/MC/WebAssembly/export-name.s
+++ llvm/test/MC/WebAssembly/export-name.s
@@ -22,5 +22,5 @@
 # CHECK-OBJ-NEXT:   - Index:   0
 # CHECK-OBJ-NEXT: Kind:FUNCTION
 # CHECK-OBJ-NEXT: Name:foo
-# CHECK-OBJ-NEXT: Flags:   [ EXPORTED ]
+# CHECK-OBJ-NEXT: Flags:   [ EXPORTED, NO_STRIP ]
 # CHECK-OBJ-NEXT: Function:0
Index: llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
===
--- llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
+++ llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
@@ -722,6 +722,7 @@
   auto WasmSym = cast(Ctx.getOrCreateSymbol(SymName));
   WasmSym->setExportName(ExportName);
   TOut.emitExportName(WasmSym, ExportName);
+  Out.EmitSymbolAttribute(WasmSym, MCSA_NoDeadStrip);
 }
 
 if (DirectiveID.getString() == ".import_module") {
Index: clang/test/CodeGen/wasm-export-name.c
===
--- clang/test/CodeGen/wasm-export-name.c
+++ clang/test/CodeGen/wasm-export-name.c
@@ -6,6 +6,8 @@
   return 43;
 }
 
+// CHECK: @llvm.used = appending global [1 x i8*] [i8* bitcast (i32 ()* @foo to i8*)]
+
 // CHECK: define i32 @foo() [[A:#[0-9]+]]
 
 // CHECK: attributes [[A]] = {{{.*}} "wasm-export-name"="bar" {{.*}}}
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -5772,8 +5772,8 @@
   if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, ))
 return;
 
-  FD->addAttr(::new (S.Context)
-  WebAssemblyExportNameAttr(S.Context, AL, Str));
+  D->addAttr(::new (S.Context) WebAssemblyExportNameAttr(S.Context, AL, Str));
+  D->addAttr(UsedAttr::CreateImplicit(S.Context));
 }
 
 static void handleWebAssemblyImportModuleAttr(Sema , Decl *D, const ParsedAttr ) {