[llvm-dev] Adding a function type qualifier with particular keyword

Tim Northover via llvm-dev llvm-dev at lists.llvm.org
Sat Sep 23 12:30:25 PDT 2017

> For the purpose of a research project, I want to add a function type
> modifier as an extension to LLVM that looks like

Do you really need it to be part of the function's type? That brings
massive extra complexity, especially when C++ and its overloading
rules are involved.

Modifying a function's definition is a lot simpler. At the C/C++ level
you'd add a custom "__attribute__((whatever))", of which plenty
already exist. Since this records register usage Clang should probably
just add an LLVM function attribute saying the same thing. Then each
backend you want to support should look for that LLVM attribute, tot
up the registers just before emission and save them somewhere (a
separate section of the .o file?).

Basically you'd want some limited Clang support for forwarding a new
attribute, and a new LLVM backend pass in each target you supported to
save the correct info if needed.



More information about the llvm-dev mailing list