[llvm-commits] [llvm] r45913 - in /llvm/trunk: include/llvm/Instructions.h lib/VMCore/Instructions.cpp

Evan Cheng evan.cheng at apple.com
Sat Jan 12 10:57:32 PST 2008


Author: evancheng
Date: Sat Jan 12 12:57:32 2008
New Revision: 45913

URL: http://llvm.org/viewvc/llvm-project?rev=45913&view=rev
Log:
Add hasByValArgument() to test if a call instruction has byval argument(s).

Modified:
    llvm/trunk/include/llvm/Instructions.h
    llvm/trunk/lib/VMCore/Instructions.cpp

Modified: llvm/trunk/include/llvm/Instructions.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Instructions.h?rev=45913&r1=45912&r2=45913&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Instructions.h (original)
+++ llvm/trunk/include/llvm/Instructions.h Sat Jan 12 12:57:32 2008
@@ -944,6 +944,9 @@
   /// @brief Determine if the call returns a structure.
   bool isStructReturn() const;
 
+  /// @brief Determine if any call argument is an aggregate passed by value.
+  bool hasByValArgument() const;
+
   /// getCalledFunction - Return the function being called by this instruction
   /// if it is a direct call.  If it is a call through a function pointer,
   /// return null.

Modified: llvm/trunk/lib/VMCore/Instructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=45913&r1=45912&r2=45913&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Instructions.cpp (original)
+++ llvm/trunk/lib/VMCore/Instructions.cpp Sat Jan 12 12:57:32 2008
@@ -404,6 +404,17 @@
   return paramHasAttr(1, ParamAttr::StructRet);
 }
 
+/// @brief Determine if any call argument is an aggregate passed by value.
+bool CallInst::hasByValArgument() const {
+  const Value *Callee = getCalledValue();
+  const PointerType *CalleeTy = cast<PointerType>(Callee->getType());
+  const FunctionType *FTy = cast<FunctionType>(CalleeTy->getElementType());
+  for (unsigned i = 1, e = FTy->getNumParams()+1; i != e; ++i)
+    if (paramHasAttr(i, ParamAttr::ByVal))
+      return true;
+  return false;
+}
+
 void CallInst::setDoesNotThrow(bool doesNotThrow) {
   const ParamAttrsList *PAL = getParamAttrs();
   if (doesNotThrow)





More information about the llvm-commits mailing list