[llvm] d6de5f1 - [SVFS] Inject TLI Mappings in VFABI attribute.

Francesco Petrogalli via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 27 06:28:58 PST 2020



> On Jan 27, 2020, at 7:54 AM, Benjamin Kramer <benny.kra at gmail.com> wrote:
> 
> On Sat, Nov 16, 2019 at 5:20 PM Francesco Petrogalli via llvm-commits
> <llvm-commits at lists.llvm.org> wrote:
>> +  // Make function declaration (without a body) "sticky" in the IR by
>> +  // listing it in the @llvm.compiler.used intrinsic.
>> +  assert(!VectorF->size() && "VFABI attribute requires `@llvm.compiler.used` "
>> +                             "only on declarations.");
>> +  appendToCompilerUsed(*M, {VectorF});
>> +  LLVM_DEBUG(dbgs() << DEBUG_TYPE << ": Adding `" << VFName
>> +                    << "` to `@llvm.compiler.used`.\n");
>> +  ++NumCompUsedAdded;
> 
> Sorry for resurrecting an old change, but what's the reason for making
> functions sticky? In XLA I'm seeing a bunch of functions that get
> inlined and then stick around unused because of being in
> llvm.compiler.used without any other users.
> 
> - Ben



Hi Ben,

It is needed for function declarations that need to be carried to the vectorizer even if they don’t have any use before vectorization.

The use case is explained in this RFC: http://lists.llvm.org/pipermail/llvm-dev/2019-June/133484.html

I have highlighted the paragraph that describes why we need that.

```
The IR attribute is used in conjunction with the vector function
declarations or definitions that are available in the module. Each
mangled name in the `vector-function-abi-attribute` is be associated to
a correspondent declaration/definition in the module. Such definition is
provided by the front-end. The vector function declaration or definition
is passed as an argument to the `llvm.compiler.used` intrinsic to
prevent the compiler from removing it from the module (for example when
the OpenMP mapping mechanism is used via C header file).
```

If this is causing you problems, we might need to rethink the mechanism that ensures the availability of the vector declaration when auto-vectorizing loops.

Kind regards,

Francesco




More information about the llvm-commits mailing list