Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is LLVM metadata

Tags:

llvm

These might be very basic questions..

1) What is LLVM metadata and how do I use it in my program? I've read all the documentation, but I don't understand how to use it.

2) How to I add my personal metadata in a file?

Thanks in advance!

like image 901
ConsistentProgrammer Avatar asked Dec 26 '22 18:12

ConsistentProgrammer


1 Answers

The best source of information would be the blog post from 2010 that introduced metadata into LLVM IR - Extensible Metadata in LLVM IR. The first paragraph mentions the motivation:

This metadata could be used to influence language-specific optimization passes (for example, Type Based Alias Analysis in C), tag information for a custom code generator, or pass through information to link time optimization.

But reall, read all of if for the historical details.

The main "client" of metadata in LLVM is currently debug info. It's used by the front-end (e.g. Clang) to tag the LLVM IR it generates with debug information that correlates IR to the source code it came from. This same metadata is later translated to platform specific debug info such as DWARF by the code emitters.

like image 84
Eli Bendersky Avatar answered Dec 31 '22 13:12

Eli Bendersky