[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 06:38:47 PDT 2021


madhur13490 created this revision.
madhur13490 added reviewers: arsenm, rampitec.
Herald added subscribers: dexonsmith, hiraditya.
madhur13490 requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.

Inline asm is a black-box to compilers and
many compilers don't analyze the statement
to draw any conclusion. Typically the asm
statement can be an arbitrary piece of code
which could have an indirect call. The current
function doesn't behave so as it returns
false when inlineasm is present.

This patch adds a flag to isIndirectCall()
which would allow analyses to consider that
inline asm may have an indirect call. Default value
of this flag is false to retain the current behaviour.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98780

Files:
  llvm/include/llvm/IR/InstrTypes.h
  llvm/lib/IR/Instructions.cpp


Index: llvm/lib/IR/Instructions.cpp
===================================================================
--- llvm/lib/IR/Instructions.cpp
+++ llvm/lib/IR/Instructions.cpp
@@ -282,11 +282,11 @@
   return cast<CallBrInst>(this)->getNumIndirectDests() + 1;
 }
 
-bool CallBase::isIndirectCall() const {
+bool CallBase::isIndirectCall(const bool InlineAsmMayHaveIndirectCall) const {
   const Value *V = getCalledOperand();
   if (isa<Function>(V) || isa<Constant>(V))
     return false;
-  return !isInlineAsm();
+  return InlineAsmMayHaveIndirectCall == isInlineAsm();
 }
 
 /// Tests if this call site must be tail call optimized. Only a CallInst can
Index: llvm/include/llvm/IR/InstrTypes.h
===================================================================
--- llvm/include/llvm/IR/InstrTypes.h
+++ llvm/include/llvm/IR/InstrTypes.h
@@ -1398,7 +1398,8 @@
   }
 
   /// Return true if the callsite is an indirect call.
-  bool isIndirectCall() const;
+  /// Optionally consider if inline asm may have an indirect call.
+  bool isIndirectCall(const bool InlineAsmMayHaveIndirectCall = false) const;
 
   /// Determine whether the passed iterator points to the callee operand's Use.
   bool isCallee(Value::const_user_iterator UI) const {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98780.331256.patch
Type: text/x-patch
Size: 1237 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210317/057fac62/attachment.bin>


More information about the llvm-commits mailing list