Mapping document questions

These questions are all related to the “Mapping High-Level Constructs to LLVM IR” document:

  1. What are the \01 characters that are prefixed to dllimport Windows symbols for? I have never seem them before so I am unsure if they are Clang/LLVM-specific?

  2. Anybody interested in explaining the zero cost exception handling mechanism using an existing example from the Mapping document? This requires coding up a working example in LLVM IR or simplifying a compiler-generated example so that it becomes easy to read.

  3. Anybody interested in explaining the various forms of constant expressions that exist in LLVM IR?

  4. Do any of you have a simple yet realistic example of an address-space cast?

  5. Anybody interested in documenting the insertvalue and extractvalue instructions? I haven’t figured out how to get a structure into a register yet.

  6. Anybody interested in documenting closures?

P.S. I sent off the document to the LLVM-commits list earlier today, but David Blaikie pointed out that the document should be in a state where it can be published before committing it, so that’s what I am working on now.

For the time being, the document can be found at:

https://github.com/archfrog/llvm-doc/blob/master/MappingHighLevelConstructsToLLVMIR.rst

As soon as it is ready to be published, it will be moved to the llvm/docs folder.

– Mikael

These questions are all related to the "Mapping High-Level Constructs to
LLVM IR" document:

1. What are the \01 characters that are prefixed to dllimport Windows
symbols for? I have never seem them before so I am unsure if they are
Clang/LLVM-specific?

I expect it's some form of mangling that is recognized by the
linker/loader, and I doubt it's LLVM-specific. You'll probably want to look
on MSDN. btw, ObjC also uses something like this in its mangling.

2. Anybody interested in explaining the zero cost exception handling
mechanism using an existing example from the Mapping document? This
requires coding up a working example in LLVM IR or simplifying a
compiler-generated example so that it becomes easy to read.

Maybe try looking at the C++ abi spec? <
http://mentorembedded.github.io/cxx-abi/abi-eh.html> Alternatively, try
looking at the source code of some existing frontends which use zero cost
exception handling. As far as I understand it, there is a nontrivial
runtime component needed for doing this.

3. Anybody interested in explaining the various forms of constant
expressions that exist in LLVM IR?

I don't know very much about them, but they basically mirror the regular
instructions. I don't think it's the best-thought-out part of the IR.

4. Do any of you have a simple yet realistic example of an address-space
cast?

addrspacecast is relatively new and serves a pretty specialized purpose.
Don't worry about it.

5. Anybody interested in documenting the insertvalue and extractvalue
instructions? I haven't figured out how to get a structure into a register
yet.

I would expect a struct-typed `load` would do the trick.

6. Anybody interested in documenting closures?

The first thing you want to do is to survey the different approaches to
closures and their respective pros/cons. That's a lot more important than
giving a specific example of a particular approach. Again, looking at
existing language frontends is probably the right approach.

-- Sean Silva