4 ms·
I don't understand this fixed bug: https://llvm.org/bugs/show_bug.cgi?id=26774 https://llvm.org/bugs/show_bug.cgi?id=26774 How could foo() had ever printed "X"
by euyyn 10y ago
I don't understand this fixed bug: https://llvm.org/bugs/show_bug.cgi?id=26774 https://llvm.org/bugs/show_bug.cgi?id=26774
How could foo() had ever printed "X"?
- yurymik 10y agoBoth t0 and t1 loads are atomic, meaning you'll always get the whole object. But there's no synchronization between them and another thread can preempt the execution and change value of %ptr right after the first load.
- agumonkey 10y agoand what is %ptr ? I'm having troubles googling it.
- erichocean 10y agoI assume %ptr is a generic "variable" name[0] for a pointer reference, i.e. the address of the value being loaded atomically. You can substitute %ptr in your head for any atomic address you might want to load from. The code itself isn't well-formed because %ptr isn't actually defined anywhere—just pretend that it was. ;) [0] Technically, LLVM does not have variables (as in, names you can assign to more than once), since it's in SSA form, but I don't know what a better name would be here. :)
- agumonkey 10y agoAight, I'll need to read their docs exhaustively, I had to anyway. Thanks nonetheless.
- euyyn 10y agoThen the CSE optimization that removed the printf would be just plain wrong. Why create a more complicated scenario just to point that out?