I checked that all of these out-of-line methods previously compiled to
simple loads and bittests, so they are pretty good candidates for
inlining. In particular, arg_size() and arg_empty() are popular and are
just two loads, so they seem worth inlining.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297963
91177308-0d34-0410-b5e6-
96231b3b80d8
// Provide fast operand accessors.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
- /// Returns the type of the ret val.
- Type *getReturnType() const;
/// Returns the FunctionType for me.
- FunctionType *getFunctionType() const;
+ FunctionType *getFunctionType() const {
+ return cast<FunctionType>(getValueType());
+ }
+ /// Returns the type of the ret val.
+ Type *getReturnType() const { return getFunctionType()->getReturnType(); }
/// getContext - Return a reference to the LLVMContext associated with this
/// function.
/// isVarArg - Return true if this function takes a variable number of
/// arguments.
- bool isVarArg() const;
+ bool isVarArg() const { return getFunctionType()->isVarArg(); }
- bool isMaterializable() const;
- void setIsMaterializable(bool V);
+ bool isMaterializable() const {
+ return getGlobalObjectSubClassData() & (1 << IsMaterializableBit);
+ }
+ void setIsMaterializable(bool V) {
+ unsigned Mask = 1 << IsMaterializableBit;
+ setGlobalObjectSubClassData((~Mask & getGlobalObjectSubClassData()) |
+ (V ? Mask : 0u));
+ }
/// getIntrinsicID - This method returns the ID number of the specified
/// function, or Intrinsic::not_intrinsic if the function is not an
/// @}
- size_t arg_size() const;
- bool arg_empty() const;
+ size_t arg_size() const { return getFunctionType()->getNumParams(); }
+ bool arg_empty() const { return arg_size() == 0; }
/// \brief Check whether this function has a personality function.
bool hasPersonalityFn() const {
}
void setAlignment(unsigned Align);
- unsigned getGlobalObjectSubClassData() const;
- void setGlobalObjectSubClassData(unsigned Val);
+ unsigned getGlobalObjectSubClassData() const {
+ unsigned ValueData = getGlobalValueSubClassData();
+ return ValueData >> GlobalObjectBits;
+ }
+
+ void setGlobalObjectSubClassData(unsigned Val) {
+ unsigned OldData = getGlobalValueSubClassData();
+ setGlobalValueSubClassData((OldData & GlobalObjectMask) |
+ (Val << GlobalObjectBits));
+ assert(getGlobalObjectSubClassData() == Val && "representation error");
+ }
/// Check if this global has a custom object file section.
///
// Helper Methods in Function
//===----------------------------------------------------------------------===//
-bool Function::isMaterializable() const {
- return getGlobalObjectSubClassData() & (1 << IsMaterializableBit);
-}
-
-void Function::setIsMaterializable(bool V) {
- unsigned Mask = 1 << IsMaterializableBit;
- setGlobalObjectSubClassData((~Mask & getGlobalObjectSubClassData()) |
- (V ? Mask : 0u));
-}
-
LLVMContext &Function::getContext() const {
return getType()->getContext();
}
-FunctionType *Function::getFunctionType() const {
- return cast<FunctionType>(getValueType());
-}
-
-bool Function::isVarArg() const {
- return getFunctionType()->isVarArg();
-}
-
-Type *Function::getReturnType() const {
- return getFunctionType()->getReturnType();
-}
-
void Function::removeFromParent() {
getParent()->getFunctionList().remove(getIterator());
}
Src.setValueSubclassData(Src.getSubclassDataFromValue() | (1 << 0));
}
-size_t Function::arg_size() const {
- return getFunctionType()->getNumParams();
-}
-bool Function::arg_empty() const {
- return getFunctionType()->getNumParams() == 0;
-}
-
// dropAllReferences() - This function causes all the subinstructions to "let
// go" of all references that they are maintaining. This allows one to
// 'delete' a whole class at a time, even though there may be circular
assert(getAlignment() == Align && "Alignment representation error!");
}
-unsigned GlobalObject::getGlobalObjectSubClassData() const {
- unsigned ValueData = getGlobalValueSubClassData();
- return ValueData >> GlobalObjectBits;
-}
-
-void GlobalObject::setGlobalObjectSubClassData(unsigned Val) {
- unsigned OldData = getGlobalValueSubClassData();
- setGlobalValueSubClassData((OldData & GlobalObjectMask) |
- (Val << GlobalObjectBits));
- assert(getGlobalObjectSubClassData() == Val && "representation error");
-}
-
void GlobalObject::copyAttributesFrom(const GlobalValue *Src) {
GlobalValue::copyAttributesFrom(Src);
if (const auto *GV = dyn_cast<GlobalObject>(Src)) {