Skip to content

Commit

Permalink
[WebAssembly] Setting export_name implies llvm.used
Browse files Browse the repository at this point in the history
This change updates the clang front end to add symbols to llvm.used
when they have explicit export_name attribute.

Differential Revision: https://reviews.llvm.org/D71493
  • Loading branch information
sbc100 committed Dec 16, 2019
1 parent 376cf43 commit 0a1e349
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions clang/lib/Sema/SemaDeclAttr.cpp
Expand Up @@ -5772,8 +5772,8 @@ static void handleWebAssemblyExportNameAttr(Sema &S, Decl *D, const ParsedAttr &
if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, &ArgLoc))
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 &S, Decl *D, const ParsedAttr &AL) {
Expand Down
2 changes: 2 additions & 0 deletions clang/test/CodeGen/wasm-export-name.c
Expand Up @@ -6,6 +6,8 @@ int foo(void) {
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" {{.*}}}

0 comments on commit 0a1e349

Please sign in to comment.