Update clang to r339409.
Change-Id: I800772d2d838223be1f6b40d490c4591b937fca2
diff --git a/linux-x64/clang/include/llvm/IR/Function.h b/linux-x64/clang/include/llvm/IR/Function.h
index ec9d370..c8d6b07 100644
--- a/linux-x64/clang/include/llvm/IR/Function.h
+++ b/linux-x64/clang/include/llvm/IR/Function.h
@@ -141,6 +141,11 @@
// Provide fast operand accessors.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
+ /// Returns the number of non-debug IR instructions in this function.
+ /// This is equivalent to the sum of the sizes of each basic block contained
+ /// within this function.
+ unsigned getInstructionCount();
+
/// Returns the FunctionType for me.
FunctionType *getFunctionType() const {
return cast<FunctionType>(getValueType());
@@ -181,7 +186,7 @@
static Intrinsic::ID lookupIntrinsicID(StringRef Name);
- /// \brief Recalculate the ID for this function if it is an Intrinsic defined
+ /// Recalculate the ID for this function if it is an Intrinsic defined
/// in llvm/Intrinsics.h. Sets the intrinsic ID to Intrinsic::not_intrinsic
/// if the name of this function does not match an intrinsic in that header.
/// Note, this method does not need to be called directly, as it is called
@@ -201,34 +206,34 @@
setValueSubclassData((getSubclassDataFromValue() & 0xc00f) | (ID << 4));
}
- /// @brief Return the attribute list for this Function.
+ /// Return the attribute list for this Function.
AttributeList getAttributes() const { return AttributeSets; }
- /// @brief Set the attribute list for this Function.
+ /// Set the attribute list for this Function.
void setAttributes(AttributeList Attrs) { AttributeSets = Attrs; }
- /// @brief Add function attributes to this function.
+ /// Add function attributes to this function.
void addFnAttr(Attribute::AttrKind Kind) {
addAttribute(AttributeList::FunctionIndex, Kind);
}
- /// @brief Add function attributes to this function.
+ /// Add function attributes to this function.
void addFnAttr(StringRef Kind, StringRef Val = StringRef()) {
addAttribute(AttributeList::FunctionIndex,
Attribute::get(getContext(), Kind, Val));
}
- /// @brief Add function attributes to this function.
+ /// Add function attributes to this function.
void addFnAttr(Attribute Attr) {
addAttribute(AttributeList::FunctionIndex, Attr);
}
- /// @brief Remove function attributes from this function.
+ /// Remove function attributes from this function.
void removeFnAttr(Attribute::AttrKind Kind) {
removeAttribute(AttributeList::FunctionIndex, Kind);
}
- /// @brief Remove function attribute from this function.
+ /// Remove function attribute from this function.
void removeFnAttr(StringRef Kind) {
setAttributes(getAttributes().removeAttribute(
getContext(), AttributeList::FunctionIndex, Kind));
@@ -263,7 +268,7 @@
static ProfileCount getInvalid() { return ProfileCount(-1, PCT_Invalid); }
};
- /// \brief Set the entry count for this function.
+ /// Set the entry count for this function.
///
/// Entry count is the number of times this function was executed based on
/// pgo data. \p Imports points to a set of GUIDs that needs to
@@ -276,7 +281,7 @@
void setEntryCount(uint64_t Count, ProfileCountType Type = PCT_Real,
const DenseSet<GlobalValue::GUID> *Imports = nullptr);
- /// \brief Get the entry count for this function.
+ /// Get the entry count for this function.
///
/// Entry count is the number of times the function was executed based on
/// pgo data.
@@ -298,27 +303,27 @@
/// Get the section prefix for this function.
Optional<StringRef> getSectionPrefix() const;
- /// @brief Return true if the function has the attribute.
+ /// Return true if the function has the attribute.
bool hasFnAttribute(Attribute::AttrKind Kind) const {
return AttributeSets.hasFnAttribute(Kind);
}
- /// @brief Return true if the function has the attribute.
+ /// Return true if the function has the attribute.
bool hasFnAttribute(StringRef Kind) const {
return AttributeSets.hasFnAttribute(Kind);
}
- /// @brief Return the attribute for the given attribute kind.
+ /// Return the attribute for the given attribute kind.
Attribute getFnAttribute(Attribute::AttrKind Kind) const {
return getAttribute(AttributeList::FunctionIndex, Kind);
}
- /// @brief Return the attribute for the given attribute kind.
+ /// Return the attribute for the given attribute kind.
Attribute getFnAttribute(StringRef Kind) const {
return getAttribute(AttributeList::FunctionIndex, Kind);
}
- /// \brief Return the stack alignment for the function.
+ /// Return the stack alignment for the function.
unsigned getFnStackAlignment() const {
if (!hasFnAttribute(Attribute::StackAlignment))
return 0;
@@ -334,110 +339,110 @@
void setGC(std::string Str);
void clearGC();
- /// @brief adds the attribute to the list of attributes.
+ /// adds the attribute to the list of attributes.
void addAttribute(unsigned i, Attribute::AttrKind Kind);
- /// @brief adds the attribute to the list of attributes.
+ /// adds the attribute to the list of attributes.
void addAttribute(unsigned i, Attribute Attr);
- /// @brief adds the attributes to the list of attributes.
+ /// adds the attributes to the list of attributes.
void addAttributes(unsigned i, const AttrBuilder &Attrs);
- /// @brief adds the attribute to the list of attributes for the given arg.
+ /// adds the attribute to the list of attributes for the given arg.
void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind);
- /// @brief adds the attribute to the list of attributes for the given arg.
+ /// adds the attribute to the list of attributes for the given arg.
void addParamAttr(unsigned ArgNo, Attribute Attr);
- /// @brief adds the attributes to the list of attributes for the given arg.
+ /// adds the attributes to the list of attributes for the given arg.
void addParamAttrs(unsigned ArgNo, const AttrBuilder &Attrs);
- /// @brief removes the attribute from the list of attributes.
+ /// removes the attribute from the list of attributes.
void removeAttribute(unsigned i, Attribute::AttrKind Kind);
- /// @brief removes the attribute from the list of attributes.
+ /// removes the attribute from the list of attributes.
void removeAttribute(unsigned i, StringRef Kind);
- /// @brief removes the attributes from the list of attributes.
+ /// removes the attributes from the list of attributes.
void removeAttributes(unsigned i, const AttrBuilder &Attrs);
- /// @brief removes the attribute from the list of attributes.
+ /// removes the attribute from the list of attributes.
void removeParamAttr(unsigned ArgNo, Attribute::AttrKind Kind);
- /// @brief removes the attribute from the list of attributes.
+ /// removes the attribute from the list of attributes.
void removeParamAttr(unsigned ArgNo, StringRef Kind);
- /// @brief removes the attribute from the list of attributes.
+ /// removes the attribute from the list of attributes.
void removeParamAttrs(unsigned ArgNo, const AttrBuilder &Attrs);
- /// @brief check if an attributes is in the list of attributes.
+ /// check if an attributes is in the list of attributes.
bool hasAttribute(unsigned i, Attribute::AttrKind Kind) const {
return getAttributes().hasAttribute(i, Kind);
}
- /// @brief check if an attributes is in the list of attributes.
+ /// check if an attributes is in the list of attributes.
bool hasParamAttribute(unsigned ArgNo, Attribute::AttrKind Kind) const {
return getAttributes().hasParamAttribute(ArgNo, Kind);
}
- /// @brief gets the attribute from the list of attributes.
+ /// gets the attribute from the list of attributes.
Attribute getAttribute(unsigned i, Attribute::AttrKind Kind) const {
return AttributeSets.getAttribute(i, Kind);
}
- /// @brief gets the attribute from the list of attributes.
+ /// gets the attribute from the list of attributes.
Attribute getAttribute(unsigned i, StringRef Kind) const {
return AttributeSets.getAttribute(i, Kind);
}
- /// @brief adds the dereferenceable attribute to the list of attributes.
+ /// adds the dereferenceable attribute to the list of attributes.
void addDereferenceableAttr(unsigned i, uint64_t Bytes);
- /// @brief adds the dereferenceable attribute to the list of attributes for
+ /// adds the dereferenceable attribute to the list of attributes for
/// the given arg.
void addDereferenceableParamAttr(unsigned ArgNo, uint64_t Bytes);
- /// @brief adds the dereferenceable_or_null attribute to the list of
+ /// adds the dereferenceable_or_null attribute to the list of
/// attributes.
void addDereferenceableOrNullAttr(unsigned i, uint64_t Bytes);
- /// @brief adds the dereferenceable_or_null attribute to the list of
+ /// adds the dereferenceable_or_null attribute to the list of
/// attributes for the given arg.
void addDereferenceableOrNullParamAttr(unsigned ArgNo, uint64_t Bytes);
- /// @brief Extract the alignment for a call or parameter (0=unknown).
+ /// Extract the alignment for a call or parameter (0=unknown).
unsigned getParamAlignment(unsigned ArgNo) const {
return AttributeSets.getParamAlignment(ArgNo);
}
- /// @brief Extract the number of dereferenceable bytes for a call or
+ /// Extract the number of dereferenceable bytes for a call or
/// parameter (0=unknown).
/// @param i AttributeList index, referring to a return value or argument.
uint64_t getDereferenceableBytes(unsigned i) const {
return AttributeSets.getDereferenceableBytes(i);
}
- /// @brief Extract the number of dereferenceable bytes for a parameter.
+ /// Extract the number of dereferenceable bytes for a parameter.
/// @param ArgNo Index of an argument, with 0 being the first function arg.
uint64_t getParamDereferenceableBytes(unsigned ArgNo) const {
return AttributeSets.getParamDereferenceableBytes(ArgNo);
}
- /// @brief Extract the number of dereferenceable_or_null bytes for a call or
+ /// Extract the number of dereferenceable_or_null bytes for a call or
/// parameter (0=unknown).
/// @param i AttributeList index, referring to a return value or argument.
uint64_t getDereferenceableOrNullBytes(unsigned i) const {
return AttributeSets.getDereferenceableOrNullBytes(i);
}
- /// @brief Extract the number of dereferenceable_or_null bytes for a
+ /// Extract the number of dereferenceable_or_null bytes for a
/// parameter.
/// @param ArgNo AttributeList ArgNo, referring to an argument.
uint64_t getParamDereferenceableOrNullBytes(unsigned ArgNo) const {
return AttributeSets.getParamDereferenceableOrNullBytes(ArgNo);
}
- /// @brief Determine if the function does not access memory.
+ /// Determine if the function does not access memory.
bool doesNotAccessMemory() const {
return hasFnAttribute(Attribute::ReadNone);
}
@@ -445,7 +450,7 @@
addFnAttr(Attribute::ReadNone);
}
- /// @brief Determine if the function does not access or only reads memory.
+ /// Determine if the function does not access or only reads memory.
bool onlyReadsMemory() const {
return doesNotAccessMemory() || hasFnAttribute(Attribute::ReadOnly);
}
@@ -453,7 +458,7 @@
addFnAttr(Attribute::ReadOnly);
}
- /// @brief Determine if the function does not access or only writes memory.
+ /// Determine if the function does not access or only writes memory.
bool doesNotReadMemory() const {
return doesNotAccessMemory() || hasFnAttribute(Attribute::WriteOnly);
}
@@ -461,14 +466,14 @@
addFnAttr(Attribute::WriteOnly);
}
- /// @brief Determine if the call can access memmory only using pointers based
+ /// Determine if the call can access memmory only using pointers based
/// on its arguments.
bool onlyAccessesArgMemory() const {
return hasFnAttribute(Attribute::ArgMemOnly);
}
void setOnlyAccessesArgMemory() { addFnAttr(Attribute::ArgMemOnly); }
- /// @brief Determine if the function may only access memory that is
+ /// Determine if the function may only access memory that is
/// inaccessible from the IR.
bool onlyAccessesInaccessibleMemory() const {
return hasFnAttribute(Attribute::InaccessibleMemOnly);
@@ -477,7 +482,7 @@
addFnAttr(Attribute::InaccessibleMemOnly);
}
- /// @brief Determine if the function may only access memory that is
+ /// Determine if the function may only access memory that is
/// either inaccessible from the IR or pointed to by its arguments.
bool onlyAccessesInaccessibleMemOrArgMem() const {
return hasFnAttribute(Attribute::InaccessibleMemOrArgMemOnly);
@@ -486,7 +491,7 @@
addFnAttr(Attribute::InaccessibleMemOrArgMemOnly);
}
- /// @brief Determine if the function cannot return.
+ /// Determine if the function cannot return.
bool doesNotReturn() const {
return hasFnAttribute(Attribute::NoReturn);
}
@@ -497,7 +502,7 @@
/// Determine if the function should not perform indirect branch tracking.
bool doesNoCfCheck() const { return hasFnAttribute(Attribute::NoCfCheck); }
- /// @brief Determine if the function cannot unwind.
+ /// Determine if the function cannot unwind.
bool doesNotThrow() const {
return hasFnAttribute(Attribute::NoUnwind);
}
@@ -505,7 +510,7 @@
addFnAttr(Attribute::NoUnwind);
}
- /// @brief Determine if the call cannot be duplicated.
+ /// Determine if the call cannot be duplicated.
bool cannotDuplicate() const {
return hasFnAttribute(Attribute::NoDuplicate);
}
@@ -513,7 +518,7 @@
addFnAttr(Attribute::NoDuplicate);
}
- /// @brief Determine if the call is convergent.
+ /// Determine if the call is convergent.
bool isConvergent() const {
return hasFnAttribute(Attribute::Convergent);
}
@@ -524,7 +529,7 @@
removeFnAttr(Attribute::Convergent);
}
- /// @brief Determine if the call has sideeffects.
+ /// Determine if the call has sideeffects.
bool isSpeculatable() const {
return hasFnAttribute(Attribute::Speculatable);
}
@@ -541,7 +546,7 @@
addFnAttr(Attribute::NoRecurse);
}
- /// @brief True if the ABI mandates (or the user requested) that this
+ /// True if the ABI mandates (or the user requested) that this
/// function be in a unwind table.
bool hasUWTable() const {
return hasFnAttribute(Attribute::UWTable);
@@ -550,19 +555,19 @@
addFnAttr(Attribute::UWTable);
}
- /// @brief True if this function needs an unwind table.
+ /// True if this function needs an unwind table.
bool needsUnwindTableEntry() const {
return hasUWTable() || !doesNotThrow();
}
- /// @brief Determine if the function returns a structure through first
+ /// Determine if the function returns a structure through first
/// or second pointer argument.
bool hasStructRetAttr() const {
return AttributeSets.hasParamAttribute(0, Attribute::StructRet) ||
AttributeSets.hasParamAttribute(1, Attribute::StructRet);
}
- /// @brief Determine if the parameter or return value is marked with NoAlias
+ /// Determine if the parameter or return value is marked with NoAlias
/// attribute.
bool returnDoesNotAlias() const {
return AttributeSets.hasAttribute(AttributeList::ReturnIndex,
@@ -679,30 +684,30 @@
size_t arg_size() const { return NumArgs; }
bool arg_empty() const { return arg_size() == 0; }
- /// \brief Check whether this function has a personality function.
+ /// Check whether this function has a personality function.
bool hasPersonalityFn() const {
return getSubclassDataFromValue() & (1<<3);
}
- /// \brief Get the personality function associated with this function.
+ /// Get the personality function associated with this function.
Constant *getPersonalityFn() const;
void setPersonalityFn(Constant *Fn);
- /// \brief Check whether this function has prefix data.
+ /// Check whether this function has prefix data.
bool hasPrefixData() const {
return getSubclassDataFromValue() & (1<<1);
}
- /// \brief Get the prefix data associated with this function.
+ /// Get the prefix data associated with this function.
Constant *getPrefixData() const;
void setPrefixData(Constant *PrefixData);
- /// \brief Check whether this function has prologue data.
+ /// Check whether this function has prologue data.
bool hasPrologueData() const {
return getSubclassDataFromValue() & (1<<2);
}
- /// \brief Get the prologue data associated with this function.
+ /// Get the prologue data associated with this function.
Constant *getPrologueData() const;
void setPrologueData(Constant *PrologueData);
@@ -762,12 +767,12 @@
/// setjmp or other function that gcc recognizes as "returning twice".
bool callsFunctionThatReturnsTwice() const;
- /// \brief Set the attached subprogram.
+ /// Set the attached subprogram.
///
/// Calls \a setMetadata() with \a LLVMContext::MD_dbg.
void setSubprogram(DISubprogram *SP);
- /// \brief Get the attached subprogram.
+ /// Get the attached subprogram.
///
/// Calls \a getMetadata() with \a LLVMContext::MD_dbg and casts the result
/// to \a DISubprogram.
@@ -776,6 +781,12 @@
/// Returns true if we should emit debug info for profiling.
bool isDebugInfoForProfiling() const;
+ /// Check if null pointer dereferencing is considered undefined behavior for
+ /// the function.
+ /// Return value: false => null pointer dereference is undefined.
+ /// Return value: true => null pointer dereference is not undefined.
+ bool nullPointerIsDefined() const;
+
private:
void allocHungoffUselist();
template<int Idx> void setHungoffOperand(Constant *C);
@@ -788,6 +799,13 @@
void setValueSubclassDataBit(unsigned Bit, bool On);
};
+/// Check whether null pointer dereferencing is considered undefined behavior
+/// for a given function or an address space.
+/// Null pointer access in non-zero address space is not considered undefined.
+/// Return value: false => null pointer dereference is undefined.
+/// Return value: true => null pointer dereference is not undefined.
+bool NullPointerIsDefined(const Function *F, unsigned AS = 0);
+
template <>
struct OperandTraits<Function> : public HungoffOperandTraits<3> {};