7

The LLVM IR doc discusses the IR in detail, much of which is clear. However, I get particularly confused with the Linkage Types. The linkage types apart from private, internal, external become quite confusing without an example.

Can someone throw some light here? (Probably relating the use-cases with a language like C/C++?)

(I am trying to understand the IR clearly, since I am building analyzers for the LLVM modules.)

codeman48
  • 1,330
  • 11
  • 17
  • It's explained rather well in the online documentation, what specifics of them are not sure about? – Frank C. Nov 18 '17 at 09:53
  • 2
    I am unable to imagine the concrete use-cases for the theory given for each one of them (apart from the given three types). Some examples or reference to a good resource would be very helpful here. – codeman48 Nov 21 '17 at 18:51

1 Answers1

1

LLVM's linkage definition is complicated as it must be able to represent notions from different programming languages, systems, object file formats etc.

The only definitive reference is the code. In particular look at how clang translates from C++ standard linkage to its own codegen linkage in ASTContext::GetGVALinkageForFunction and from there into llvm's in CodeGenModule::getLLVMLinkageForDeclarator.

And then there's of course some code (haven't found it yet) translating LLVM linkage into an object file equivalent like COMDATs or weak symbols using e.g. GlobalValue::isWeakForLinker

The appending linkage is a very special low-level one used for constructing arrays of pointers to global constructors for example.

Trass3r
  • 5,858
  • 2
  • 30
  • 45