[llvm] r174864 - [tsan/msan] adding thread_safety and uninitialized_checks attributes

Kostya Serebryany kcc at google.com
Mon Feb 11 00:13:55 PST 2013


Author: kcc
Date: Mon Feb 11 02:13:54 2013
New Revision: 174864

URL: http://llvm.org/viewvc/llvm-project?rev=174864&view=rev
Log:
[tsan/msan] adding thread_safety and uninitialized_checks attributes

Modified:
    llvm/trunk/docs/LangRef.rst
    llvm/trunk/include/llvm/IR/Attributes.h
    llvm/trunk/lib/AsmParser/LLLexer.cpp
    llvm/trunk/lib/AsmParser/LLParser.cpp
    llvm/trunk/lib/AsmParser/LLToken.h
    llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
    llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
    llvm/trunk/lib/IR/Attributes.cpp
    llvm/trunk/lib/IR/Verifier.cpp
    llvm/trunk/test/Bitcode/attributes.ll
    llvm/trunk/utils/llvm.grm
    llvm/trunk/utils/vim/llvm.vim

Modified: llvm/trunk/docs/LangRef.rst
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.rst?rev=174864&r1=174863&r2=174864&view=diff
==============================================================================
--- llvm/trunk/docs/LangRef.rst (original)
+++ llvm/trunk/docs/LangRef.rst Mon Feb 11 02:13:54 2013
@@ -909,6 +909,12 @@ example:
     If a function that has an ``sspstrong`` attribute is inlined into a
     function that doesn't have an ``sspstrong`` attribute, then the
     resulting function will have an ``sspstrong`` attribute.
+``thread_safety``
+    This attribute indicates that the thread safety analysis is enabled
+    for this function.
+``uninitialized_checks``
+    This attribute indicates that the checks for uses of uninitialized
+    memory are enabled.
 ``uwtable``
     This attribute indicates that the ABI being targeted requires that
     an unwind table entry be produce for this function even if we can

Modified: llvm/trunk/include/llvm/IR/Attributes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Attributes.h?rev=174864&r1=174863&r2=174864&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Attributes.h (original)
+++ llvm/trunk/include/llvm/IR/Attributes.h Mon Feb 11 02:13:54 2013
@@ -95,6 +95,8 @@ public:
     StackProtectReq,       ///< Stack protection required.
     StackProtectStrong,    ///< Strong Stack protection.
     StructRet,             ///< Hidden pointer to structure to return
+    ThreadSafety,          ///< Thread safety checking is on.
+    UninitializedChecks,   ///< Checking for uses of uninitialized memory is on.
     UWTable,               ///< Function must be in a unwind table
     ZExt,                  ///< Zero extended before/after call
 
@@ -507,6 +509,8 @@ public:
       .removeAttribute(Attribute::NonLazyBind)
       .removeAttribute(Attribute::ReturnsTwice)
       .removeAttribute(Attribute::AddressSafety)
+      .removeAttribute(Attribute::ThreadSafety)
+      .removeAttribute(Attribute::UninitializedChecks)
       .removeAttribute(Attribute::MinSize)
       .removeAttribute(Attribute::NoDuplicate);
   }

Modified: llvm/trunk/lib/AsmParser/LLLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLLexer.cpp?rev=174864&r1=174863&r2=174864&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLLexer.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLLexer.cpp Mon Feb 11 02:13:54 2013
@@ -578,6 +578,8 @@ lltok::Kind LLLexer::LexIdentifier() {
   KEYWORD(ssp);
   KEYWORD(sspreq);
   KEYWORD(sspstrong);
+  KEYWORD(thread_safety);
+  KEYWORD(uninitialized_checks);
   KEYWORD(uwtable);
   KEYWORD(zeroext);
 

Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=174864&r1=174863&r2=174864&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Mon Feb 11 02:13:54 2013
@@ -922,6 +922,8 @@ bool LLParser::ParseFnAttributeValuePair
     case lltok::kw_ssp:             B.addAttribute(Attribute::StackProtect); break;
     case lltok::kw_sspreq:          B.addAttribute(Attribute::StackProtectReq); break;
     case lltok::kw_sspstrong:       B.addAttribute(Attribute::StackProtectStrong); break;
+    case lltok::kw_thread_safety:   B.addAttribute(Attribute::ThreadSafety); break;
+    case lltok::kw_uninitialized_checks: B.addAttribute(Attribute::UninitializedChecks); break;
     case lltok::kw_uwtable:         B.addAttribute(Attribute::UWTable); break;
 
     // Error handling.
@@ -1161,7 +1163,8 @@ bool LLParser::ParseOptionalParamAttrs(A
     case lltok::kw_noredzone:      case lltok::kw_noimplicitfloat:
     case lltok::kw_naked:          case lltok::kw_nonlazybind:
     case lltok::kw_address_safety: case lltok::kw_minsize:
-    case lltok::kw_alignstack:
+    case lltok::kw_alignstack:     case lltok::kw_thread_safety:
+    case lltok::kw_uninitialized_checks:
       HaveError |= Error(Lex.getLoc(), "invalid use of function-only attribute");
       break;
     }
@@ -1203,6 +1206,7 @@ bool LLParser::ParseOptionalReturnAttrs(
     case lltok::kw_nonlazybind:    case lltok::kw_address_safety:
     case lltok::kw_minsize:        case lltok::kw_alignstack:
     case lltok::kw_align:          case lltok::kw_noduplicate:
+    case lltok::kw_thread_safety:  case lltok::kw_uninitialized_checks:
       HaveError |= Error(Lex.getLoc(), "invalid use of function-only attribute");
       break;
     }

Modified: llvm/trunk/lib/AsmParser/LLToken.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLToken.h?rev=174864&r1=174863&r2=174864&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLToken.h (original)
+++ llvm/trunk/lib/AsmParser/LLToken.h Mon Feb 11 02:13:54 2013
@@ -119,6 +119,8 @@ namespace lltok {
     kw_sspreq,
     kw_sspstrong,
     kw_sret,
+    kw_thread_safety,
+    kw_uninitialized_checks,
     kw_uwtable,
     kw_zeroext,
 

Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=174864&r1=174863&r2=174864&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Mon Feb 11 02:13:54 2013
@@ -444,7 +444,7 @@ static void decodeLLVMAttributesForBitco
 
   if (Alignment)
     B.addAlignmentAttr(Alignment);
-  B.addRawValue(((EncodedAttrs & (0xffffULL << 32)) >> 11) |
+  B.addRawValue(((EncodedAttrs & (0xfffffULL << 32)) >> 11) |
                 (EncodedAttrs & 0xffff));
 }
 

Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=174864&r1=174863&r2=174864&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original)
+++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Mon Feb 11 02:13:54 2013
@@ -181,7 +181,7 @@ static uint64_t encodeLLVMAttributesForB
   uint64_t EncodedAttrs = Attrs.Raw(Index) & 0xffff;
   if (Attrs.hasAttribute(Index, Attribute::Alignment))
     EncodedAttrs |= Attrs.getParamAlignment(Index) << 16;
-  EncodedAttrs |= (Attrs.Raw(Index) & (0xffffULL << 21)) << 11;
+  EncodedAttrs |= (Attrs.Raw(Index) & (0xfffffULL << 21)) << 11;
   return EncodedAttrs;
 }
 

Modified: llvm/trunk/lib/IR/Attributes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Attributes.cpp?rev=174864&r1=174863&r2=174864&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Attributes.cpp (original)
+++ llvm/trunk/lib/IR/Attributes.cpp Mon Feb 11 02:13:54 2013
@@ -205,6 +205,10 @@ std::string Attribute::getAsString() con
     return "sspstrong";
   if (hasAttribute(Attribute::StructRet))
     return "sret";
+  if (hasAttribute(Attribute::ThreadSafety))
+    return "thread_safety";
+  if (hasAttribute(Attribute::UninitializedChecks))
+    return "uninitialized_checks";
   if (hasAttribute(Attribute::UWTable))
     return "uwtable";
   if (hasAttribute(Attribute::ZExt))
@@ -382,6 +386,8 @@ uint64_t AttributeImpl::getAttrMask(Attr
   case Attribute::MinSize:         return 1ULL << 33;
   case Attribute::NoDuplicate:     return 1ULL << 34;
   case Attribute::StackProtectStrong: return 1ULL << 35;
+  case Attribute::ThreadSafety:    return 1ULL << 36;
+  case Attribute::UninitializedChecks: return 1ULL << 37;
   }
   llvm_unreachable("Unsupported attribute type");
 }

Modified: llvm/trunk/lib/IR/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=174864&r1=174863&r2=174864&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Verifier.cpp (original)
+++ llvm/trunk/lib/IR/Verifier.cpp Mon Feb 11 02:13:54 2013
@@ -651,6 +651,8 @@ void Verifier::VerifyParameterAttrs(Attr
           !Attrs.hasAttribute(Idx, Attribute::NonLazyBind) &&
           !Attrs.hasAttribute(Idx, Attribute::ReturnsTwice) &&
           !Attrs.hasAttribute(Idx, Attribute::AddressSafety) &&
+          !Attrs.hasAttribute(Idx, Attribute::ThreadSafety) &&
+          !Attrs.hasAttribute(Idx, Attribute::UninitializedChecks) &&
           !Attrs.hasAttribute(Idx, Attribute::MinSize),
           "Some attributes in '" + Attrs.getAsString(Idx) +
           "' only apply to functions!", V);

Modified: llvm/trunk/test/Bitcode/attributes.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/attributes.ll?rev=174864&r1=174863&r2=174864&view=diff
==============================================================================
--- llvm/trunk/test/Bitcode/attributes.ll (original)
+++ llvm/trunk/test/Bitcode/attributes.ll Mon Feb 11 02:13:54 2013
@@ -162,3 +162,13 @@ define void @f27() address_safety
 {
         ret void;
 }
+define void @f28() thread_safety
+; CHECK: define void @f28() thread_safety
+{
+        ret void;
+}
+define void @f29() uninitialized_checks
+; CHECK: define void @f29() uninitialized_checks
+{
+        ret void;
+}

Modified: llvm/trunk/utils/llvm.grm
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/llvm.grm?rev=174864&r1=174863&r2=174864&view=diff
==============================================================================
--- llvm/trunk/utils/llvm.grm (original)
+++ llvm/trunk/utils/llvm.grm Mon Feb 11 02:13:54 2013
@@ -175,6 +175,8 @@ FuncAttr      ::= noreturn
  | returns_twice
  | nonlazybind
  | address_safety
+ | thread_safety
+ | uninitialized_checks
  ;
 
 OptFuncAttrs  ::= + _ | OptFuncAttrs FuncAttr ;

Modified: llvm/trunk/utils/vim/llvm.vim
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/vim/llvm.vim?rev=174864&r1=174863&r2=174864&view=diff
==============================================================================
--- llvm/trunk/utils/vim/llvm.vim (original)
+++ llvm/trunk/utils/vim/llvm.vim Mon Feb 11 02:13:54 2013
@@ -55,6 +55,7 @@ syn keyword llvmKeyword singlethread spi
 syn keyword llvmKeyword sspstrong tail target thread_local to triple
 syn keyword llvmKeyword unnamed_addr unordered uwtable volatile weak weak_odr
 syn keyword llvmKeyword x86_fastcallcc x86_stdcallcc x86_thiscallcc zeroext
+syn keyword llvmKeyword thread_safety uninitialized_checks
 
 " Obsolete keywords.
 syn keyword llvmError  getresult begin end





More information about the llvm-commits mailing list