[llvm] 296ccef - [WebAssembly] EmscriptenEHSjLj: Mark __invoke_ functions as imported
Mikael Holmén via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 3 02:49:40 PDT 2020
Hi,
I noticed on one of my organization's build bots that runs with
sanatizers that we got a warning about a leak with this commit. So when
running the testcase
test/CodeGen/WebAssembly/irreducible-cfg-exceptions.ll
build-sana/bin/llc < test/CodeGen/WebAssembly/irreducible-cfg-
exceptions.ll -asm-verbose=false -verify-machineinstrs -disable-block-
placement -wasm-disable-explicit-locals -wasm-keep-registers -enable-
emscripten-cxx-exceptions | build-sana/bin/FileCheck
test/CodeGen/WebAssembly/irreducible-cfg-exceptions.ll
I get
=================================================================
==5081==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 32 byte(s) in 1 object(s) allocated from:
#0 0x421d520 (/data/repo/master/llvm/build-sana/bin/llc+0x421d520)
#1 0x46a9ec9 (/data/repo/master/llvm/build-sana/bin/llc+0x46a9ec9)
#2 0x676cc32 (/data/repo/master/llvm/build-sana/bin/llc+0x676cc32)
#3 0x7bbf0ca (/data/repo/master/llvm/build-sana/bin/llc+0x7bbf0ca)
#4 0x8e2374d (/data/repo/master/llvm/build-sana/bin/llc+0x8e2374d)
#5 0x8e245e0 (/data/repo/master/llvm/build-sana/bin/llc+0x8e245e0)
#6 0x4228f89 (/data/repo/master/llvm/build-sana/bin/llc+0x4228f89)
#7 0x42235a0 (/data/repo/master/llvm/build-sana/bin/llc+0x42235a0)
#8 0x7f50ee2f4b96 (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
SUMMARY: AddressSanitizer: 32 byte(s) leaked in 1 allocation(s).
/Mikael
On Wed, 2020-04-01 at 16:33 -0700, Sam Clegg via llvm-commits wrote:
> Author: Sam Clegg
> Date: 2020-04-01T16:33:33-07:00
> New Revision: 296ccef70363df9195bc678ad5501dd44de7f8fb
>
> URL:
> https://protect2.fireeye.com/v1/url?k=6f7ff692-33f65951-6f7fb609-0cc47ad93d36-d092eb1748b9557d&q=1&e=1ca40782-7747-4f20-89e4-55dbb09d830d&u=https%3A%2F%2Fgithub.com%2Fllvm%2Fllvm-project%2Fcommit%2F296ccef70363df9195bc678ad5501dd44de7f8fb
> DIFF:
> https://protect2.fireeye.com/v1/url?k=4a3efd3f-16b752fc-4a3ebda4-0cc47ad93d36-ac161843750d844e&q=1&e=1ca40782-7747-4f20-89e4-55dbb09d830d&u=https%3A%2F%2Fgithub.com%2Fllvm%2Fllvm-project%2Fcommit%2F296ccef70363df9195bc678ad5501dd44de7f8fb.diff
>
> LOG: [WebAssembly] EmscriptenEHSjLj: Mark __invoke_ functions as
> imported
>
> This means the linker will be expect them be undefined at link time
> an
> will generate imports from the `env` module rather than reporting
> undefined externals.
>
> Differential Revision: https://reviews.llvm.org/D77192
>
> Added:
>
>
> Modified:
> llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
> llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll
>
> Removed:
>
>
>
> #####################################################################
> ###########
> diff --git
> a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
> b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
> index 89265a3a9520..c8878a48b243 100644
> ---
> a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
> +++
> b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
> @@ -344,6 +344,21 @@ static std::string getSignature(FunctionType
> *FTy) {
> return Sig;
> }
>
> +static void markAsImported(Function *F) {
> + // Tell the linker that this function is expected to be imported
> from the
> + // 'env' module.
> + if (!F->hasFnAttribute("wasm-import-module")) {
> + llvm::AttrBuilder B;
> + B.addAttribute("wasm-import-module", "env");
> + F->addAttributes(llvm::AttributeList::FunctionIndex, B);
> + }
> + if (!F->hasFnAttribute("wasm-import-name")) {
> + llvm::AttrBuilder B;
> + B.addAttribute("wasm-import-name", F->getName());
> + F->addAttributes(llvm::AttributeList::FunctionIndex, B);
> + }
> +}
> +
> // Returns __cxa_find_matching_catch_N function, where N =
> NumClauses + 2.
> // This is because a landingpad instruction contains two more
> arguments, a
> // personality function and a cleanup bit, and
> __cxa_find_matching_catch_N
> @@ -360,6 +375,7 @@
> WebAssemblyLowerEmscriptenEHSjLj::getFindMatchingCatch(Module &M,
> Function *F = Function::Create(
> FTy, GlobalValue::ExternalLinkage,
> "__cxa_find_matching_catch_" + Twine(NumClauses + 2), &M);
> + markAsImported(F);
> FindMatchingCatches[NumClauses] = F;
> return F;
> }
> @@ -469,6 +485,7 @@ Function
> *WebAssemblyLowerEmscriptenEHSjLj::getInvokeWrapper(CallOrInvoke *CI)
> {
> CalleeFTy->isVarArg());
> Function *F =
> Function::Create(FTy, GlobalValue::ExternalLinkage,
> "__invoke_" + Sig, M);
> + markAsImported(F);
> InvokeWrappers[Sig] = F;
> return F;
> }
>
> diff --git a/llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll
> b/llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll
> index cad6c4ac855b..ad42cc5f8615 100644
> --- a/llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll
> +++ b/llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll
> @@ -308,6 +308,10 @@ attributes #0 = { returns_twice }
> attributes #1 = { noreturn }
> attributes #2 = { nounwind }
> attributes #3 = { allocsize(0) }
> +; CHECK: attributes #{{[0-9]+}} = { "wasm-import-module"="env"
> "wasm-import-name"="__invoke_void" }
> +; CHECK: attributes #{{[0-9]+}} = { "wasm-import-module"="env"
> "wasm-import-name"="__cxa_find_matching_catch_3" }
> +; CHECK: attributes #{{[0-9]+}} = { "wasm-import-module"="env"
> "wasm-import-name"="__invoke_i8*_i32_%struct.__jmp_buf_tag*" }
> +; CHECK: attributes #{{[0-9]+}} = { "wasm-import-module"="env"
> "wasm-import-name"="__invoke_void_%struct.__jmp_buf_tag*_i32" }
> ; CHECK: attributes #[[ALLOCSIZE_ATTR]] = { allocsize(1) }
>
> !llvm.dbg.cu = !{!2}
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list