From f4a5498ab44f06b2b74da7fda92521f34bb22367 Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Sat, 12 Jan 2008 18:57:32 +0000 Subject: Add hasByValArgument() to test if a call instruction has byval argument(s). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45913 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/VMCore/Instructions.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'lib') diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp index d8bcb31..a9cc275 100644 --- a/lib/VMCore/Instructions.cpp +++ b/lib/VMCore/Instructions.cpp @@ -404,6 +404,17 @@ bool CallInst::isStructReturn() const { 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(Callee->getType()); + const FunctionType *FTy = cast(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) -- cgit v1.1