7 ms·
LLVM Programmer’s Manual
- webkike 10y agoI believe that the heavy use of iterators in LLVM was a mistake. The ownership mechanics has never not been a source of extreme confusion and annoying bugs. But, it's still a great backend.
- Joky 10y agoCan you elaborate? Especially I don't really see the relation between "iterators" and "ownership".
- DannyBee 10y agoErrr? I'm aware of maybe one iterator invalidation bug in the like the past year, and one or two ownership bugs, mostly in badly written code. On the list of "stuff llvm got wrong", i feel like this wouldn't even make the top hundred.
- webkike 10y agoA large part of writing optimization passes for LLVM consists of figuring out how methods/functions interact with the iterators in terms of validation and ownership. A lot of LLVM is undocumented unfortunately and it's not always clear how they will interact with the iterators. LLVM itself does not suffer from these problems much, but writing opt passes is definitely a huge pain.
- Joky 10y agoMy experience is that LLVM uses of iterator is very coherent with what to expect from C++, and I never had any issue on this aspect. Iterator invalidation is pervasive in the STL containers, and as a C++ programmer you are supposed to know what type of container you're iterating on (in LLVM iterating over a basic block is a linked-list, iterator are not invalidated for instance).
- Rarebox 10y agoNotably, exceptions are not used. Instead errors are handled with assertions and error objects.
- adamnemecek 10y agoI feel like people are realizing that exceptions were a bad idea. They are kind of like gotos.
- SamReidHughes 10y agoC++ is memory-unsafe and has a special relationship with the feature. Projects that start without pervasive exception safety in mind are usually stuck that way.
- evincarofautumn 10y agoExceptions are much worse than “goto”, in my experience. “throw” is basically a dynamically bound “return” statement—it’s hard to reason about where you’ll end up, because it depends on the call stack above you, and the type of object you decided to throw. The same throw site might jump to many different, unrelated parts of the program. Real exception safety is almost as hard to get right as concurrency, and for similar reasons.
- adamnemecek 10y agoI was referring to old school gotos, not like those in c. But yeah, we are in the same page.
- slezyr 10y ago> Real exception safety is almost as hard to get right as concurrency, and for similar reasons It's even harder to get right concurrency with exceptions :D
- quotemstr 10y ago> It's even harder to get right concurrency with exceptions No it isn't.
- jokoon 10y agoI wonder how hard it is for a coder with not a lot of knowledge about parsers and LR/LL stuff to quickly define a language and translate it in LLIR. That could be a fun thing to have a language competition that way, to see which language "feels" good: easy to read, expressive, etc.
- davorb 10y agoAssuming that you are somewhat familiar with assembly programming and know how to produce a syntax tree, getting it to output compilable LLVM IR should take you at most a couple of days.
- musha68k 10y agoI was just looking into LLVM the other day as I was researching the possibilities of cross-compiling Rust to m68k on my Mac and now I simply can't stop reading up on LLVM! Support for Motorola 68000 has never been finished but this guy's abandoned fork offers an interesting glimpse into how one might start going about it though: https://github.com/kwaters/llvm-m68k/commits/m68k https://github.com/kwaters/llvm-m68k/commits/m68k A bit over my head for now but I'm using this as a fun occasion to get back into "proper" computer science. Dabbling is my favourite learning mode so consulting the LLVM Programmer's Manual while hacking on a more isolated and really simple task is something I'm very much looking forward to at this point. Still, if there is anybody with more knowledge who could chip in a bit on supporting m68k or LLVM in general I'd be super curious to read about it :)
- vbit 10y agoDo LLVM have any support for coroutines? If I wanted to implement a language with Lua-style coroutines, could I target LLVM?
- Others 10y agoUnfortunately, I don't think it does currently. I think you'd have to reimplement them yourself on top of LLVM... That might change though, this co-routine proposal just came up on the mailing list: https://github.com/GorNishanov/llvm/blob/coro-rfc/docs/Coroutines.rst https://github.com/GorNishanov/llvm/blob/coro-rfc/docs/Corou...