diff options
author | Diego Novillo <dnovillo@google.com> | 2013-05-24 12:26:52 +0000 |
---|---|---|
committer | Diego Novillo <dnovillo@google.com> | 2013-05-24 12:26:52 +0000 |
commit | c63995394de60996ebfe52a47cf2e3a0716d7e3c (patch) | |
tree | a74f82a4691d823a2fc5ab2d87c5798f68174cf1 /llvm/lib/IR | |
parent | 646ec67e252f7daa5fe1f5d7719f247c89293b0c (diff) | |
download | bcm5719-llvm-c63995394de60996ebfe52a47cf2e3a0716d7e3c.tar.gz bcm5719-llvm-c63995394de60996ebfe52a47cf2e3a0716d7e3c.zip |
Add a new function attribute 'cold' to functions.
Other than recognizing the attribute, the patch does little else.
It changes the branch probability analyzer so that edges into
blocks postdominated by a cold function are given low weight.
Added analysis and code generation tests. Added documentation for the
new attribute.
llvm-svn: 182638
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r-- | llvm/lib/IR/Attributes.cpp | 3 | ||||
-rw-r--r-- | llvm/lib/IR/Verifier.cpp | 3 |
2 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp index 4fe6f9ddc59..e48ebb13352 100644 --- a/llvm/lib/IR/Attributes.cpp +++ b/llvm/lib/IR/Attributes.cpp @@ -217,6 +217,8 @@ std::string Attribute::getAsString(bool InAttrGrp) const { return "uwtable"; if (hasAttribute(Attribute::ZExt)) return "zeroext"; + if (hasAttribute(Attribute::Cold)) + return "cold"; // FIXME: These should be output like this: // @@ -396,6 +398,7 @@ uint64_t AttributeImpl::getAttrMask(Attribute::AttrKind Val) { case Attribute::SanitizeMemory: return 1ULL << 37; case Attribute::NoBuiltin: return 1ULL << 38; case Attribute::Returned: return 1ULL << 39; + case Attribute::Cold: return 1ULL << 40; } llvm_unreachable("Unsupported attribute type"); } diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index d106173b521..a94c1566a20 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -692,7 +692,8 @@ void Verifier::VerifyAttributeTypes(AttributeSet Attrs, unsigned Idx, I->getKindAsEnum() == Attribute::SanitizeMemory || I->getKindAsEnum() == Attribute::MinSize || I->getKindAsEnum() == Attribute::NoDuplicate || - I->getKindAsEnum() == Attribute::NoBuiltin) { + I->getKindAsEnum() == Attribute::NoBuiltin || + I->getKindAsEnum() == Attribute::Cold) { if (!isFunction) CheckFailed("Attribute '" + I->getKindAsString() + "' only applies to functions!", V); |