[PATCH] D98780: [IR] Add opt-in flag to isIndirectCall() to consider inlineasm

Madhur Amilkanthwar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 17 12:33:42 PDT 2021


madhur13490 added a comment.

In D98780#2632539 <https://reviews.llvm.org/D98780#2632539>, @arsenm wrote:

> I don't think this should be done. The point of the function is to check if the IR instruction is an indirect call. inline is a different entity

But in that case the current function should not even do anything related to inlineAsm(). Treating the presence of inlineAsm is different for difference clients and that is what the flag offers.



================
Comment at: llvm/lib/IR/Instructions.cpp:289
     return false;
-  return !isInlineAsm();
+  return InlineAsmMayHaveIndirectCall == isInlineAsm();
 }
----------------
rampitec wrote:
> madhur13490 wrote:
> > rampitec wrote:
> > > It will give wrong answer for non-asm. "return !isInlineAsm() || !InlineAsmMayHaveIndirectCall;"
> > I don't think why it would return wrong answer. Here is the truth table of the operation:
> > 
> > 1. InlineAsmMayHaveIndirectCall = false, isInlineAsm() = false --> return "true" (as expected)
> > 2. InlineAsmMayHaveIndirectCall = false, isInlineAsm() = true --> return "false" (as expected)
> > 3. InlineAsmMayHaveIndirectCall = true, isInlineAsm() = true --> return "true" (as expected)
> > 4. InlineAsmMayHaveIndirectCall = true, isInlineAsm() = false --> return "false" (as expected)
> > 
> > 1 & 2 above are according to today's behavior. 3 & 4 are the new ones. Which of the above is incorrect?
> > 
> > FWIW, "==" operator enacts XNOR for bools.
> > 
> Last case is incorrect. If it is not isInlineAsm() we should return true, just like now. It does not matter what inline asm may or may not contain then.
> 
> But my condition is also wrong. I think it is "return !isInlineAsm() || InlineAsmMayHaveIndirectCall;".
No, if you're passing inlineAsmMayHaveIndirectCall = true then you're considering that the statement might have one inside the block box.

So, it essentially means "isInlineAsm() == presence of indirect call". If inlineAsm() = true then you have indirect call (condition 3). If inlineAsm() = false then you don't have indirect call (condition 4). 

The function should either choose to NOT consider anything about inlineAsm() or should provide flexibility to consider. In latter case, it is not useful and we have to check !callee everywhere. 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98780/new/

https://reviews.llvm.org/D98780



More information about the llvm-commits mailing list