[LLVMdev] [RFC] Defining Infinite Loops

Krzysztof Parzyszek kparzysz at codeaurora.org
Fri Jul 17 08:08:38 PDT 2015


On 7/16/2015 1:00 AM, Chandler Carruth wrote:
>
> As for why I'm particularly interested in this being a property of the
> loop, consider if you were to have a mixture of Java and C++ code, all
> compiled to LLVM. How do you inline between them?

That's what I was wondering too.

C++:

void foo() {
   for (unsigned i = 0; i < 3; ++i)
     java_infinite_loop();
}


Java:

public void java_infinite_loop() {
   while (true)
     ;
}


Once we inline, we get something like

void foo() {
   for (i = 0; i < 3; ++i)  // marked as terminating
     while (true)           // marked as infinite
       ;
}

Is this program ill-formed?  If not, how would we resolve the 
conflicting information?


On the other hand, how much is there to gain by exploiting the C++'s 
assumption?  Or to put it another way, what would be lose in practice if 
we were to ignore it?

-Krzysztof

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, 
hosted by The Linux Foundation



More information about the llvm-dev mailing list