diff options
| author | Evan Cheng <evan.cheng@apple.com> | 2008-01-12 18:57:32 +0000 |
|---|---|---|
| committer | Evan Cheng <evan.cheng@apple.com> | 2008-01-12 18:57:32 +0000 |
| commit | 09dde6001df11ec681a7d537f356b4ae76e72eaf (patch) | |
| tree | 1af8a3c2b2045fc692211283b7b00627203c42ae | |
| parent | 4f6c81ac68ffe4bb9296d445dade6df63937f5f1 (diff) | |
| download | bcm5719-llvm-09dde6001df11ec681a7d537f356b4ae76e72eaf.tar.gz bcm5719-llvm-09dde6001df11ec681a7d537f356b4ae76e72eaf.zip | |
Add hasByValArgument() to test if a call instruction has byval argument(s).
llvm-svn: 45913
| -rw-r--r-- | llvm/include/llvm/Instructions.h | 3 | ||||
| -rw-r--r-- | llvm/lib/VMCore/Instructions.cpp | 11 |
2 files changed, 14 insertions, 0 deletions
diff --git a/llvm/include/llvm/Instructions.h b/llvm/include/llvm/Instructions.h index 1594a0ace67..76190f146d5 100644 --- a/llvm/include/llvm/Instructions.h +++ b/llvm/include/llvm/Instructions.h @@ -944,6 +944,9 @@ public: /// @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. diff --git a/llvm/lib/VMCore/Instructions.cpp b/llvm/lib/VMCore/Instructions.cpp index d8bcb31a476..a9cc275b548 100644 --- a/llvm/lib/VMCore/Instructions.cpp +++ b/llvm/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<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) |

