[llvm-dev] RFC: Strong GC References in LLVM
Sanjoy Das via llvm-dev
llvm-dev at lists.llvm.org
Fri Jul 15 15:30:55 PDT 2016
Hi Daniel,
Daniel Berlin wrote:
> // ptr_a and ptr_b are NoAlias, ptr_a holds 0 to begin with.
>
> ThreadA:
> while(true) { store volatile i32 42, i32* %ptr_b }
> store atomic i32 42, i32* %ptr_a
>
> ThreadB:
> %val = load atomic i32, i32* %ptr_a
> assert(%val is not 42) // The store is "guarded" by an inf loop
>
>
> We can't reorder the store to ptr_a to before the infinite loop. The
> volatile store is there to make the infinite loop well defined.
>
>
> These do not have hidden control flow. It is actually well defined it
> just literallly involves other instructions :)
As written above, sure; but the `while (true)` could be inside a
nounwind function (that does not return). So it is not sufficient to
just look for calls to unknown functions in a function body to
conclude that it is alwaysreturn, it isn't sufficient to look for
llvm::Loop's either since we could have cycles not describable as
loops.
I'm not claiming that ^ is new information, btw, I'm justifying why I
specifically brought up the "while(true)" example. :)
> Note that gcc will optionally connect the infinite loop itself to the
> exit block with a fake edge if you want
> (you can add/remove fake edges on a per-opt basis).
Does GCC's notion of a "loop" (unlike LLVM) include all potentially
infinite control flow?
-- Sanjoy
More information about the llvm-dev
mailing list