Unify clang/llvm attributes for asan/tsan/msan (LLVM part)

These are two related changes (one in llvm, one in clang).
LLVM: 
- rename address_safety => sanitize_address (the enum value is the same, so we preserve binary compatibility with old bitcode)
- rename thread_safety => sanitize_thread
- rename no_uninitialized_checks -> sanitize_memory

CLANG: 
- add __attribute__((no_sanitize_address)) as a synonym for __attribute__((no_address_safety_analysis))
- add __attribute__((no_sanitize_thread))
- add __attribute__((no_sanitize_memory))

for S in address thread memory
If -fsanitize=S is present and __attribute__((no_sanitize_S)) is not
set llvm attribute sanitize_S


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176075 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Kostya Serebryany
2013-02-26 06:58:09 +00:00
parent ce522ee0a2
commit 8eec41fc77
25 changed files with 127 additions and 127 deletions

View File

@@ -793,9 +793,6 @@ example:
define void @f() alwaysinline optsize { ... } define void @f() alwaysinline optsize { ... }
define void @f() optsize { ... } define void @f() optsize { ... }
``address_safety``
This attribute indicates that the address safety analysis is enabled
for this function.
``alignstack(<n>)`` ``alignstack(<n>)``
This attribute indicates that, when emitting the prologue and This attribute indicates that, when emitting the prologue and
epilogue, the backend should forcibly align the stack pointer. epilogue, the backend should forcibly align the stack pointer.
@@ -873,6 +870,15 @@ example:
``setjmp`` is an example of such a function. The compiler disables ``setjmp`` is an example of such a function. The compiler disables
some optimizations (like tail calls) in the caller of these some optimizations (like tail calls) in the caller of these
functions. functions.
``sanitize_address``
This attribute indicates that AddressSanitizer checks
(dynamic address safety analysis) are enabled for this function.
``sanitize_memory``
This attribute indicates that MemorySanitizer checks (dynamic detection
of accesses to uninitialized memory) are enabled for this function.
``sanitize_thread``
This attribute indicates that ThreadSanitizer checks
(dynamic thread safety analysis) are enabled for this function.
``ssp`` ``ssp``
This attribute indicates that the function should emit a stack This attribute indicates that the function should emit a stack
smashing protector. It is in the form of a "canary" --- a random value smashing protector. It is in the form of a "canary" --- a random value
@@ -914,12 +920,6 @@ example:
If a function that has an ``sspstrong`` attribute is inlined into a If a function that has an ``sspstrong`` attribute is inlined into a
function that doesn't have an ``sspstrong`` attribute, then the function that doesn't have an ``sspstrong`` attribute, then the
resulting function will have an ``sspstrong`` attribute. 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`` ``uwtable``
This attribute indicates that the ABI being targeted requires that This attribute indicates that the ABI being targeted requires that
an unwind table entry be produce for this function even if we can an unwind table entry be produce for this function even if we can

View File

@@ -63,7 +63,6 @@ public:
enum AttrKind { enum AttrKind {
// IR-Level Attributes // IR-Level Attributes
None, ///< No attributes have been set None, ///< No attributes have been set
AddressSafety, ///< Address safety checking is on.
Alignment, ///< Alignment of parameter (5 bits) Alignment, ///< Alignment of parameter (5 bits)
///< stored as log2 of alignment with +1 bias ///< stored as log2 of alignment with +1 bias
///< 0 means unaligned (different from align(1)) ///< 0 means unaligned (different from align(1))
@@ -98,8 +97,9 @@ public:
StackProtectReq, ///< Stack protection required. StackProtectReq, ///< Stack protection required.
StackProtectStrong, ///< Strong Stack protection. StackProtectStrong, ///< Strong Stack protection.
StructRet, ///< Hidden pointer to structure to return StructRet, ///< Hidden pointer to structure to return
ThreadSafety, ///< Thread safety checking is on. SanitizeAddress, ///< AddressSanitizer is on.
UninitializedChecks, ///< Checking for uses of uninitialized memory is on. SanitizeThread, ///< ThreadSanitizer is on.
SanitizeMemory, ///< MemorySanitizer is on.
UWTable, ///< Function must be in a unwind table UWTable, ///< Function must be in a unwind table
ZExt, ///< Zero extended before/after call ZExt, ///< Zero extended before/after call

View File

@@ -287,7 +287,7 @@ getLoadLoadClobberFullWidthSize(const Value *MemLocBase, int64_t MemLocOffs,
// Load widening is hostile to ThreadSanitizer: it may cause false positives // Load widening is hostile to ThreadSanitizer: it may cause false positives
// or make the reports more cryptic (access sizes are wrong). // or make the reports more cryptic (access sizes are wrong).
if (LI->getParent()->getParent()->getAttributes(). if (LI->getParent()->getParent()->getAttributes().
hasAttribute(AttributeSet::FunctionIndex, Attribute::ThreadSafety)) hasAttribute(AttributeSet::FunctionIndex, Attribute::SanitizeThread))
return 0; return 0;
// Get the base of this load. // Get the base of this load.
@@ -334,7 +334,7 @@ getLoadLoadClobberFullWidthSize(const Value *MemLocBase, int64_t MemLocOffs,
if (LIOffs+NewLoadByteSize > MemLocEnd && if (LIOffs+NewLoadByteSize > MemLocEnd &&
LI->getParent()->getParent()->getAttributes(). LI->getParent()->getParent()->getAttributes().
hasAttribute(AttributeSet::FunctionIndex, Attribute::AddressSafety)) hasAttribute(AttributeSet::FunctionIndex, Attribute::SanitizeAddress))
// We will be reading past the location accessed by the original program. // We will be reading past the location accessed by the original program.
// While this is safe in a regular build, Address Safety analysis tools // While this is safe in a regular build, Address Safety analysis tools
// may start reporting false warnings. So, don't do widening. // may start reporting false warnings. So, don't do widening.

View File

@@ -562,7 +562,6 @@ lltok::Kind LLLexer::LexIdentifier() {
KEYWORD(attributes); KEYWORD(attributes);
KEYWORD(address_safety);
KEYWORD(alwaysinline); KEYWORD(alwaysinline);
KEYWORD(byval); KEYWORD(byval);
KEYWORD(inlinehint); KEYWORD(inlinehint);
@@ -589,8 +588,9 @@ lltok::Kind LLLexer::LexIdentifier() {
KEYWORD(ssp); KEYWORD(ssp);
KEYWORD(sspreq); KEYWORD(sspreq);
KEYWORD(sspstrong); KEYWORD(sspstrong);
KEYWORD(thread_safety); KEYWORD(sanitize_address);
KEYWORD(uninitialized_checks); KEYWORD(sanitize_thread);
KEYWORD(sanitize_memory);
KEYWORD(uwtable); KEYWORD(uwtable);
KEYWORD(zeroext); KEYWORD(zeroext);

View File

@@ -907,29 +907,29 @@ bool LLParser::ParseFnAttributeValuePairs(AttrBuilder &B,
B.addStackAlignmentAttr(Alignment); B.addStackAlignmentAttr(Alignment);
continue; continue;
} }
case lltok::kw_address_safety: B.addAttribute(Attribute::AddressSafety); break; case lltok::kw_alwaysinline: B.addAttribute(Attribute::AlwaysInline); break;
case lltok::kw_alwaysinline: B.addAttribute(Attribute::AlwaysInline); break; case lltok::kw_inlinehint: B.addAttribute(Attribute::InlineHint); break;
case lltok::kw_inlinehint: B.addAttribute(Attribute::InlineHint); break; case lltok::kw_minsize: B.addAttribute(Attribute::MinSize); break;
case lltok::kw_minsize: B.addAttribute(Attribute::MinSize); break; case lltok::kw_naked: B.addAttribute(Attribute::Naked); break;
case lltok::kw_naked: B.addAttribute(Attribute::Naked); break; case lltok::kw_nobuiltin: B.addAttribute(Attribute::NoBuiltin); break;
case lltok::kw_nobuiltin: B.addAttribute(Attribute::NoBuiltin); break; case lltok::kw_noduplicate: B.addAttribute(Attribute::NoDuplicate); break;
case lltok::kw_noduplicate: B.addAttribute(Attribute::NoDuplicate); break; case lltok::kw_noimplicitfloat: B.addAttribute(Attribute::NoImplicitFloat); break;
case lltok::kw_noimplicitfloat: B.addAttribute(Attribute::NoImplicitFloat); break; case lltok::kw_noinline: B.addAttribute(Attribute::NoInline); break;
case lltok::kw_noinline: B.addAttribute(Attribute::NoInline); break; case lltok::kw_nonlazybind: B.addAttribute(Attribute::NonLazyBind); break;
case lltok::kw_nonlazybind: B.addAttribute(Attribute::NonLazyBind); break; case lltok::kw_noredzone: B.addAttribute(Attribute::NoRedZone); break;
case lltok::kw_noredzone: B.addAttribute(Attribute::NoRedZone); break; case lltok::kw_noreturn: B.addAttribute(Attribute::NoReturn); break;
case lltok::kw_noreturn: B.addAttribute(Attribute::NoReturn); break; case lltok::kw_nounwind: B.addAttribute(Attribute::NoUnwind); break;
case lltok::kw_nounwind: B.addAttribute(Attribute::NoUnwind); break; case lltok::kw_optsize: B.addAttribute(Attribute::OptimizeForSize); break;
case lltok::kw_optsize: B.addAttribute(Attribute::OptimizeForSize); break; case lltok::kw_readnone: B.addAttribute(Attribute::ReadNone); break;
case lltok::kw_readnone: B.addAttribute(Attribute::ReadNone); break; case lltok::kw_readonly: B.addAttribute(Attribute::ReadOnly); break;
case lltok::kw_readonly: B.addAttribute(Attribute::ReadOnly); break; case lltok::kw_returns_twice: B.addAttribute(Attribute::ReturnsTwice); break;
case lltok::kw_returns_twice: B.addAttribute(Attribute::ReturnsTwice); break; case lltok::kw_ssp: B.addAttribute(Attribute::StackProtect); break;
case lltok::kw_ssp: B.addAttribute(Attribute::StackProtect); break; case lltok::kw_sspreq: B.addAttribute(Attribute::StackProtectReq); break;
case lltok::kw_sspreq: B.addAttribute(Attribute::StackProtectReq); break; case lltok::kw_sspstrong: B.addAttribute(Attribute::StackProtectStrong); break;
case lltok::kw_sspstrong: B.addAttribute(Attribute::StackProtectStrong); break; case lltok::kw_sanitize_address: B.addAttribute(Attribute::SanitizeAddress); break;
case lltok::kw_thread_safety: B.addAttribute(Attribute::ThreadSafety); break; case lltok::kw_sanitize_thread: B.addAttribute(Attribute::SanitizeThread); break;
case lltok::kw_uninitialized_checks: B.addAttribute(Attribute::UninitializedChecks); break; case lltok::kw_sanitize_memory: B.addAttribute(Attribute::SanitizeMemory); break;
case lltok::kw_uwtable: B.addAttribute(Attribute::UWTable); break; case lltok::kw_uwtable: B.addAttribute(Attribute::UWTable); break;
// Error handling. // Error handling.
case lltok::kw_inreg: case lltok::kw_inreg:
@@ -1159,17 +1159,17 @@ bool LLParser::ParseOptionalParamAttrs(AttrBuilder &B) {
case lltok::kw_sret: B.addAttribute(Attribute::StructRet); break; case lltok::kw_sret: B.addAttribute(Attribute::StructRet); break;
case lltok::kw_zeroext: B.addAttribute(Attribute::ZExt); break; case lltok::kw_zeroext: B.addAttribute(Attribute::ZExt); break;
case lltok::kw_noreturn: case lltok::kw_nounwind: case lltok::kw_alignstack: case lltok::kw_nounwind:
case lltok::kw_uwtable: case lltok::kw_returns_twice: case lltok::kw_alwaysinline: case lltok::kw_optsize:
case lltok::kw_noinline: case lltok::kw_readnone: case lltok::kw_inlinehint: case lltok::kw_readnone:
case lltok::kw_readonly: case lltok::kw_inlinehint: case lltok::kw_minsize: case lltok::kw_readonly:
case lltok::kw_alwaysinline: case lltok::kw_optsize: case lltok::kw_naked: case lltok::kw_returns_twice:
case lltok::kw_ssp: case lltok::kw_sspreq: case lltok::kw_nobuiltin: case lltok::kw_sanitize_address:
case lltok::kw_noredzone: case lltok::kw_noimplicitfloat: case lltok::kw_noimplicitfloat: case lltok::kw_sanitize_memory:
case lltok::kw_naked: case lltok::kw_nonlazybind: case lltok::kw_noinline: case lltok::kw_sanitize_thread:
case lltok::kw_address_safety: case lltok::kw_minsize: case lltok::kw_nonlazybind: case lltok::kw_ssp:
case lltok::kw_alignstack: case lltok::kw_thread_safety: case lltok::kw_noredzone: case lltok::kw_sspreq:
case lltok::kw_nobuiltin: case lltok::kw_uninitialized_checks: case lltok::kw_noreturn: case lltok::kw_uwtable:
HaveError |= Error(Lex.getLoc(), "invalid use of function-only attribute"); HaveError |= Error(Lex.getLoc(), "invalid use of function-only attribute");
break; break;
} }
@@ -1200,19 +1200,19 @@ bool LLParser::ParseOptionalReturnAttrs(AttrBuilder &B) {
HaveError |= Error(Lex.getLoc(), "invalid use of parameter-only attribute"); HaveError |= Error(Lex.getLoc(), "invalid use of parameter-only attribute");
break; break;
case lltok::kw_noreturn: case lltok::kw_nounwind: case lltok::kw_align: case lltok::kw_noreturn:
case lltok::kw_uwtable: case lltok::kw_returns_twice: case lltok::kw_alignstack: case lltok::kw_nounwind:
case lltok::kw_noinline: case lltok::kw_readnone: case lltok::kw_alwaysinline: case lltok::kw_optsize:
case lltok::kw_readonly: case lltok::kw_inlinehint: case lltok::kw_inlinehint: case lltok::kw_readnone:
case lltok::kw_alwaysinline: case lltok::kw_optsize: case lltok::kw_minsize: case lltok::kw_readonly:
case lltok::kw_ssp: case lltok::kw_sspreq: case lltok::kw_naked: case lltok::kw_returns_twice:
case lltok::kw_sspstrong: case lltok::kw_noimplicitfloat: case lltok::kw_nobuiltin: case lltok::kw_sanitize_address:
case lltok::kw_noredzone: case lltok::kw_naked: case lltok::kw_noduplicate: case lltok::kw_sanitize_memory:
case lltok::kw_nonlazybind: case lltok::kw_address_safety: case lltok::kw_noimplicitfloat: case lltok::kw_sanitize_thread:
case lltok::kw_minsize: case lltok::kw_alignstack: case lltok::kw_noinline: case lltok::kw_ssp:
case lltok::kw_align: case lltok::kw_noduplicate: case lltok::kw_nonlazybind: case lltok::kw_sspreq:
case lltok::kw_thread_safety: case lltok::kw_uninitialized_checks: case lltok::kw_noredzone: case lltok::kw_sspstrong:
case lltok::kw_nobuiltin: case lltok::kw_uwtable:
HaveError |= Error(Lex.getLoc(), "invalid use of function-only attribute"); HaveError |= Error(Lex.getLoc(), "invalid use of function-only attribute");
break; break;
} }

View File

@@ -94,7 +94,7 @@ namespace lltok {
// Attributes: // Attributes:
kw_attributes, kw_attributes,
kw_alwaysinline, kw_alwaysinline,
kw_address_safety, kw_sanitize_address,
kw_byval, kw_byval,
kw_inlinehint, kw_inlinehint,
kw_inreg, kw_inreg,
@@ -120,8 +120,8 @@ namespace lltok {
kw_sspreq, kw_sspreq,
kw_sspstrong, kw_sspstrong,
kw_sret, kw_sret,
kw_thread_safety, kw_sanitize_thread,
kw_uninitialized_checks, kw_sanitize_memory,
kw_uwtable, kw_uwtable,
kw_zeroext, kw_zeroext,

View File

@@ -153,8 +153,8 @@ unsigned Attribute::getStackAlignment() const {
std::string Attribute::getAsString(bool InAttrGrp) const { std::string Attribute::getAsString(bool InAttrGrp) const {
if (!pImpl) return ""; if (!pImpl) return "";
if (hasAttribute(Attribute::AddressSafety)) if (hasAttribute(Attribute::SanitizeAddress))
return "address_safety"; return "sanitize_address";
if (hasAttribute(Attribute::AlwaysInline)) if (hasAttribute(Attribute::AlwaysInline))
return "alwaysinline"; return "alwaysinline";
if (hasAttribute(Attribute::ByVal)) if (hasAttribute(Attribute::ByVal))
@@ -207,10 +207,10 @@ std::string Attribute::getAsString(bool InAttrGrp) const {
return "sspstrong"; return "sspstrong";
if (hasAttribute(Attribute::StructRet)) if (hasAttribute(Attribute::StructRet))
return "sret"; return "sret";
if (hasAttribute(Attribute::ThreadSafety)) if (hasAttribute(Attribute::SanitizeThread))
return "thread_safety"; return "sanitize_thread";
if (hasAttribute(Attribute::UninitializedChecks)) if (hasAttribute(Attribute::SanitizeMemory))
return "uninitialized_checks"; return "sanitize_memory";
if (hasAttribute(Attribute::UWTable)) if (hasAttribute(Attribute::UWTable))
return "uwtable"; return "uwtable";
if (hasAttribute(Attribute::ZExt)) if (hasAttribute(Attribute::ZExt))
@@ -386,12 +386,12 @@ uint64_t AttributeImpl::getAttrMask(Attribute::AttrKind Val) {
case Attribute::ReturnsTwice: return 1 << 29; case Attribute::ReturnsTwice: return 1 << 29;
case Attribute::UWTable: return 1 << 30; case Attribute::UWTable: return 1 << 30;
case Attribute::NonLazyBind: return 1U << 31; case Attribute::NonLazyBind: return 1U << 31;
case Attribute::AddressSafety: return 1ULL << 32; case Attribute::SanitizeAddress: return 1ULL << 32;
case Attribute::MinSize: return 1ULL << 33; case Attribute::MinSize: return 1ULL << 33;
case Attribute::NoDuplicate: return 1ULL << 34; case Attribute::NoDuplicate: return 1ULL << 34;
case Attribute::StackProtectStrong: return 1ULL << 35; case Attribute::StackProtectStrong: return 1ULL << 35;
case Attribute::ThreadSafety: return 1ULL << 36; case Attribute::SanitizeThread: return 1ULL << 36;
case Attribute::UninitializedChecks: return 1ULL << 37; case Attribute::SanitizeMemory: return 1ULL << 37;
case Attribute::NoBuiltin: return 1ULL << 38; case Attribute::NoBuiltin: return 1ULL << 38;
} }
llvm_unreachable("Unsupported attribute type"); llvm_unreachable("Unsupported attribute type");
@@ -1119,9 +1119,9 @@ void AttrBuilder::removeFunctionOnlyAttrs() {
.removeAttribute(Attribute::UWTable) .removeAttribute(Attribute::UWTable)
.removeAttribute(Attribute::NonLazyBind) .removeAttribute(Attribute::NonLazyBind)
.removeAttribute(Attribute::ReturnsTwice) .removeAttribute(Attribute::ReturnsTwice)
.removeAttribute(Attribute::AddressSafety) .removeAttribute(Attribute::SanitizeAddress)
.removeAttribute(Attribute::ThreadSafety) .removeAttribute(Attribute::SanitizeThread)
.removeAttribute(Attribute::UninitializedChecks) .removeAttribute(Attribute::SanitizeMemory)
.removeAttribute(Attribute::MinSize) .removeAttribute(Attribute::MinSize)
.removeAttribute(Attribute::NoDuplicate) .removeAttribute(Attribute::NoDuplicate)
.removeAttribute(Attribute::NoBuiltin); .removeAttribute(Attribute::NoBuiltin);

View File

@@ -650,9 +650,9 @@ void Verifier::VerifyParameterAttrs(AttributeSet Attrs, uint64_t Idx, Type *Ty,
!Attrs.hasAttribute(Idx, Attribute::UWTable) && !Attrs.hasAttribute(Idx, Attribute::UWTable) &&
!Attrs.hasAttribute(Idx, Attribute::NonLazyBind) && !Attrs.hasAttribute(Idx, Attribute::NonLazyBind) &&
!Attrs.hasAttribute(Idx, Attribute::ReturnsTwice) && !Attrs.hasAttribute(Idx, Attribute::ReturnsTwice) &&
!Attrs.hasAttribute(Idx, Attribute::AddressSafety) && !Attrs.hasAttribute(Idx, Attribute::SanitizeAddress) &&
!Attrs.hasAttribute(Idx, Attribute::ThreadSafety) && !Attrs.hasAttribute(Idx, Attribute::SanitizeThread) &&
!Attrs.hasAttribute(Idx, Attribute::UninitializedChecks) && !Attrs.hasAttribute(Idx, Attribute::SanitizeMemory) &&
!Attrs.hasAttribute(Idx, Attribute::MinSize) && !Attrs.hasAttribute(Idx, Attribute::MinSize) &&
!Attrs.hasAttribute(Idx, Attribute::NoBuiltin), !Attrs.hasAttribute(Idx, Attribute::NoBuiltin),
"Some attributes in '" + Attrs.getAsString(Idx) + "Some attributes in '" + Attrs.getAsString(Idx) +

View File

@@ -1098,11 +1098,11 @@ bool AddressSanitizer::runOnFunction(Function &F) {
DEBUG(dbgs() << "ASAN instrumenting:\n" << F << "\n"); DEBUG(dbgs() << "ASAN instrumenting:\n" << F << "\n");
initializeCallbacks(*F.getParent()); initializeCallbacks(*F.getParent());
// If needed, insert __asan_init before checking for AddressSafety attr. // If needed, insert __asan_init before checking for SanitizeAddress attr.
maybeInsertAsanInitAtFunctionEntry(F); maybeInsertAsanInitAtFunctionEntry(F);
if (!F.getAttributes().hasAttribute(AttributeSet::FunctionIndex, if (!F.getAttributes().hasAttribute(AttributeSet::FunctionIndex,
Attribute::AddressSafety)) Attribute::SanitizeAddress))
return false; return false;
if (!ClDebugFunc.empty() && ClDebugFunc != F.getName()) if (!ClDebugFunc.empty() && ClDebugFunc != F.getName())

View File

@@ -157,17 +157,17 @@ define void @f26() nonlazybind
ret void; ret void;
} }
define void @f27() address_safety define void @f27() sanitize_address
; CHECK: define void @f27() #17 ; CHECK: define void @f27() #17
{ {
ret void; ret void;
} }
define void @f28() thread_safety define void @f28() sanitize_thread
; CHECK: define void @f28() #18 ; CHECK: define void @f28() #18
{ {
ret void; ret void;
} }
define void @f29() uninitialized_checks define void @f29() sanitize_memory
; CHECK: define void @f29() #19 ; CHECK: define void @f29() #19
{ {
ret void; ret void;
@@ -196,7 +196,7 @@ define void @f30() "cpu"="cortex-a8"
; CHECK: attributes #14 = { returns_twice } ; CHECK: attributes #14 = { returns_twice }
; CHECK: attributes #15 = { uwtable } ; CHECK: attributes #15 = { uwtable }
; CHECK: attributes #16 = { nonlazybind } ; CHECK: attributes #16 = { nonlazybind }
; CHECK: attributes #17 = { address_safety } ; CHECK: attributes #17 = { sanitize_address }
; CHECK: attributes #18 = { thread_safety } ; CHECK: attributes #18 = { sanitize_thread }
; CHECK: attributes #19 = { uninitialized_checks } ; CHECK: attributes #19 = { sanitize_memory }
; CHECK: attributes #20 = { "cpu"="cortex-a8" } ; CHECK: attributes #20 = { "cpu"="cortex-a8" }

View File

@@ -431,7 +431,7 @@ return: ; preds = %entry
; uitofp expands to an FCMOV instruction which splits the basic block. ; uitofp expands to an FCMOV instruction which splits the basic block.
; Make sure the live range of %AL isn't split. ; Make sure the live range of %AL isn't split.
@.str = private unnamed_addr constant { [1 x i8], [63 x i8] } zeroinitializer, align 32 @.str = private unnamed_addr constant { [1 x i8], [63 x i8] } zeroinitializer, align 32
define void @pr13188(i64* nocapture %this) uwtable ssp address_safety align 2 { define void @pr13188(i64* nocapture %this) uwtable ssp sanitize_address align 2 {
entry: entry:
%x7 = load i64* %this, align 8 %x7 = load i64* %this, align 8
%sub = add i64 %x7, -1 %sub = add i64 %x7, -1

View File

@@ -36,14 +36,14 @@ target triple = "i386-unknown-linux-gnu"
@ff_mlp_firorder_7 = external global i8 @ff_mlp_firorder_7 = external global i8
@ff_mlp_firorder_8 = external global i8 @ff_mlp_firorder_8 = external global i8
define void @ff_mlp_init_x86(%struct.DSPContext* nocapture %c, %struct.AVCodecContext* nocapture %avctx) nounwind address_safety { define void @ff_mlp_init_x86(%struct.DSPContext* nocapture %c, %struct.AVCodecContext* nocapture %avctx) nounwind sanitize_address {
entry: entry:
%mlp_filter_channel = getelementptr inbounds %struct.DSPContext* %c, i32 0, i32 131 %mlp_filter_channel = getelementptr inbounds %struct.DSPContext* %c, i32 0, i32 131
store void (i32*, i32*, i32, i32, i32, i32, i32, i32*)* @mlp_filter_channel_x86, void (i32*, i32*, i32, i32, i32, i32, i32, i32*)** %mlp_filter_channel, align 4, !tbaa !0 store void (i32*, i32*, i32, i32, i32, i32, i32, i32*)* @mlp_filter_channel_x86, void (i32*, i32*, i32, i32, i32, i32, i32, i32*)** %mlp_filter_channel, align 4, !tbaa !0
ret void ret void
} }
define internal void @mlp_filter_channel_x86(i32* %state, i32* %coeff, i32 %firorder, i32 %iirorder, i32 %filter_shift, i32 %mask, i32 %blocksize, i32* %sample_buffer) nounwind address_safety { define internal void @mlp_filter_channel_x86(i32* %state, i32* %coeff, i32 %firorder, i32 %iirorder, i32 %filter_shift, i32 %mask, i32 %blocksize, i32* %sample_buffer) nounwind sanitize_address {
entry: entry:
%filter_shift.addr = alloca i32, align 4 %filter_shift.addr = alloca i32, align 4
%mask.addr = alloca i32, align 4 %mask.addr = alloca i32, align 4

View File

@@ -11,9 +11,9 @@ target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f3
@f = global %struct_of_7_bytes_4_aligned zeroinitializer, align 4 @f = global %struct_of_7_bytes_4_aligned zeroinitializer, align 4
; Accessing bytes 4 and 6, not ok to widen to i32 if address_safety is set. ; Accessing bytes 4 and 6, not ok to widen to i32 if sanitize_address is set.
define i32 @test_widening_bad(i8* %P) nounwind ssp noredzone address_safety { define i32 @test_widening_bad(i8* %P) nounwind ssp noredzone sanitize_address {
entry: entry:
%tmp = load i8* getelementptr inbounds (%struct_of_7_bytes_4_aligned* @f, i64 0, i32 1), align 4 %tmp = load i8* getelementptr inbounds (%struct_of_7_bytes_4_aligned* @f, i64 0, i32 1), align 4
%conv = zext i8 %tmp to i32 %conv = zext i8 %tmp to i32
@@ -36,7 +36,7 @@ define void @end_test_widening_bad() {
;; Accessing bytes 4 and 5. Ok to widen to i16. ;; Accessing bytes 4 and 5. Ok to widen to i16.
define i32 @test_widening_ok(i8* %P) nounwind ssp noredzone address_safety { define i32 @test_widening_ok(i8* %P) nounwind ssp noredzone sanitize_address {
entry: entry:
%tmp = load i8* getelementptr inbounds (%struct_of_7_bytes_4_aligned* @f, i64 0, i32 1), align 4 %tmp = load i8* getelementptr inbounds (%struct_of_7_bytes_4_aligned* @f, i64 0, i32 1), align 4
%conv = zext i8 %tmp to i32 %conv = zext i8 %tmp to i32

View File

@@ -5,7 +5,7 @@
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
target triple = "x86_64-unknown-linux-gnu" target triple = "x86_64-unknown-linux-gnu"
define i32 @test_load(i32* %a) address_safety { define i32 @test_load(i32* %a) sanitize_address {
; CHECK: @test_load ; CHECK: @test_load
; CHECK-NOT: load ; CHECK-NOT: load
; CHECK: %[[LOAD_ADDR:[^ ]*]] = ptrtoint i32* %a to i64 ; CHECK: %[[LOAD_ADDR:[^ ]*]] = ptrtoint i32* %a to i64
@@ -38,7 +38,7 @@ entry:
ret i32 %tmp1 ret i32 %tmp1
} }
define void @test_store(i32* %a) address_safety { define void @test_store(i32* %a) sanitize_address {
; CHECK: @test_store ; CHECK: @test_store
; CHECK-NOT: store ; CHECK-NOT: store
; CHECK: %[[STORE_ADDR:[^ ]*]] = ptrtoint i32* %a to i64 ; CHECK: %[[STORE_ADDR:[^ ]*]] = ptrtoint i32* %a to i64
@@ -73,7 +73,7 @@ entry:
; Check that asan leaves just one alloca. ; Check that asan leaves just one alloca.
declare void @alloca_test_use([10 x i8]*) declare void @alloca_test_use([10 x i8]*)
define void @alloca_test() address_safety { define void @alloca_test() sanitize_address {
entry: entry:
%x = alloca [10 x i8], align 1 %x = alloca [10 x i8], align 1
%y = alloca [10 x i8], align 1 %y = alloca [10 x i8], align 1
@@ -89,7 +89,7 @@ entry:
; CHECK-NOT: = alloca ; CHECK-NOT: = alloca
; CHECK: ret void ; CHECK: ret void
define void @LongDoubleTest(x86_fp80* nocapture %a) nounwind uwtable address_safety { define void @LongDoubleTest(x86_fp80* nocapture %a) nounwind uwtable sanitize_address {
entry: entry:
store x86_fp80 0xK3FFF8000000000000000, x86_fp80* %a, align 16 store x86_fp80 0xK3FFF8000000000000000, x86_fp80* %a, align 16
ret void ret void
@@ -101,7 +101,7 @@ entry:
; CHECK: ret void ; CHECK: ret void
define void @i40test(i40* %a, i40* %b) nounwind uwtable address_safety { define void @i40test(i40* %a, i40* %b) nounwind uwtable sanitize_address {
entry: entry:
%t = load i40* %a %t = load i40* %a
store i40 %t, i40* %b, align 8 store i40 %t, i40* %b, align 8
@@ -115,7 +115,7 @@ define void @i40test(i40* %a, i40* %b) nounwind uwtable address_safety {
; CHECK: __asan_report_store_n{{.*}}, i64 5) ; CHECK: __asan_report_store_n{{.*}}, i64 5)
; CHECK: ret void ; CHECK: ret void
define void @i80test(i80* %a, i80* %b) nounwind uwtable address_safety { define void @i80test(i80* %a, i80* %b) nounwind uwtable sanitize_address {
entry: entry:
%t = load i80* %a %t = load i80* %a
store i80 %t, i80* %b, align 8 store i80 %t, i80* %b, align 8

View File

@@ -6,7 +6,7 @@
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu" target triple = "x86_64-unknown-linux-gnu"
define i32 @_Z3zzzi(i32 %p) nounwind uwtable address_safety { define i32 @_Z3zzzi(i32 %p) nounwind uwtable sanitize_address {
entry: entry:
%p.addr = alloca i32, align 4 %p.addr = alloca i32, align 4
%r = alloca i32, align 4 %r = alloca i32, align 4

View File

@@ -9,7 +9,7 @@ target triple = "x86_64-unknown-linux-gnu"
; CHECK: @__asan_mapping_offset = linkonce_odr constant i64 0 ; CHECK: @__asan_mapping_offset = linkonce_odr constant i64 0
; CHECK: @__asan_mapping_scale = linkonce_odr constant i64 2 ; CHECK: @__asan_mapping_scale = linkonce_odr constant i64 2
define i32 @test_load(i32* %a) address_safety { define i32 @test_load(i32* %a) sanitize_address {
; CHECK: @test_load ; CHECK: @test_load
; CHECK-NOT: load ; CHECK-NOT: load
; CHECK: %[[LOAD_ADDR:[^ ]*]] = ptrtoint i32* %a to i64 ; CHECK: %[[LOAD_ADDR:[^ ]*]] = ptrtoint i32* %a to i64

View File

@@ -5,7 +5,7 @@
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu" target triple = "x86_64-unknown-linux-gnu"
define void @_Z3barv() uwtable address_safety { define void @_Z3barv() uwtable sanitize_address {
entry: entry:
%a = alloca i32, align 4 %a = alloca i32, align 4
call void @_Z3fooPi(i32* %a) call void @_Z3fooPi(i32* %a)

View File

@@ -7,7 +7,7 @@ target triple = "x86_64-unknown-linux-gnu"
declare void @MyNoReturnFunc(i32) noreturn declare void @MyNoReturnFunc(i32) noreturn
define i32 @Call1(i8* nocapture %arg) uwtable address_safety { define i32 @Call1(i8* nocapture %arg) uwtable sanitize_address {
entry: entry:
call void @MyNoReturnFunc(i32 1) noreturn ; The call insn has noreturn attr. call void @MyNoReturnFunc(i32 1) noreturn ; The call insn has noreturn attr.
; CHECK: @Call1 ; CHECK: @Call1
@@ -17,7 +17,7 @@ entry:
unreachable unreachable
} }
define i32 @Call2(i8* nocapture %arg) uwtable address_safety { define i32 @Call2(i8* nocapture %arg) uwtable sanitize_address {
entry: entry:
call void @MyNoReturnFunc(i32 1) ; No noreturn attribure on the call. call void @MyNoReturnFunc(i32 1) ; No noreturn attribure on the call.
; CHECK: @Call2 ; CHECK: @Call2
@@ -29,7 +29,7 @@ entry:
declare i32 @__gxx_personality_v0(...) declare i32 @__gxx_personality_v0(...)
define i64 @Invoke1(i8** %esc) nounwind uwtable ssp address_safety { define i64 @Invoke1(i8** %esc) nounwind uwtable ssp sanitize_address {
entry: entry:
invoke void @MyNoReturnFunc(i32 1) invoke void @MyNoReturnFunc(i32 1)
to label %invoke.cont unwind label %lpad to label %invoke.cont unwind label %lpad

View File

@@ -23,7 +23,7 @@ entry:
ret void ret void
} }
define internal void @_GLOBAL__I_a() address_safety section ".text.startup" { define internal void @_GLOBAL__I_a() sanitize_address section ".text.startup" {
entry: entry:
call void @__cxx_global_var_init() call void @__cxx_global_var_init()
ret void ret void
@@ -40,7 +40,7 @@ entry:
; CHECK: ret ; CHECK: ret
; Check that xxx is instrumented. ; Check that xxx is instrumented.
define void @touch_xxx() address_safety { define void @touch_xxx() sanitize_address {
store i32 0, i32 *@xxx, align 4 store i32 0, i32 *@xxx, align 4
ret void ret void
; CHECK: define void @touch_xxx ; CHECK: define void @touch_xxx
@@ -49,7 +49,7 @@ define void @touch_xxx() address_safety {
} }
; Check that XXX is instrumented. ; Check that XXX is instrumented.
define void @touch_XXX() address_safety { define void @touch_XXX() sanitize_address {
store i32 0, i32 *@XXX, align 4 store i32 0, i32 *@XXX, align 4
ret void ret void
; CHECK: define void @touch_XXX ; CHECK: define void @touch_XXX
@@ -59,7 +59,7 @@ define void @touch_XXX() address_safety {
; Check that yyy is NOT instrumented (as it does not have dynamic initializer). ; Check that yyy is NOT instrumented (as it does not have dynamic initializer).
define void @touch_yyy() address_safety { define void @touch_yyy() sanitize_address {
store i32 0, i32 *@yyy, align 4 store i32 0, i32 *@yyy, align 4
ret void ret void
; CHECK: define void @touch_yyy ; CHECK: define void @touch_yyy
@@ -68,7 +68,7 @@ define void @touch_yyy() address_safety {
} }
; Check that YYY is NOT instrumented (as it does not have dynamic initializer). ; Check that YYY is NOT instrumented (as it does not have dynamic initializer).
define void @touch_YYY() address_safety { define void @touch_YYY() sanitize_address {
store i32 0, i32 *@YYY, align 4 store i32 0, i32 *@YYY, align 4
ret void ret void
; CHECK: define void @touch_YYY ; CHECK: define void @touch_YYY

View File

@@ -4,7 +4,7 @@
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
target triple = "x86_64-unknown-linux-gnu" target triple = "x86_64-unknown-linux-gnu"
define void @IncrementMe(i32* %a) address_safety { define void @IncrementMe(i32* %a) sanitize_address {
entry: entry:
%tmp1 = load i32* %a, align 4 %tmp1 = load i32* %a, align 4
%tmp2 = add i32 %tmp1, 1 %tmp2 = add i32 %tmp1, 1

View File

@@ -7,7 +7,7 @@ target triple = "x86_64-unknown-linux-gnu"
declare void @llvm.lifetime.start(i64, i8* nocapture) nounwind declare void @llvm.lifetime.start(i64, i8* nocapture) nounwind
declare void @llvm.lifetime.end(i64, i8* nocapture) nounwind declare void @llvm.lifetime.end(i64, i8* nocapture) nounwind
define void @lifetime_no_size() address_safety { define void @lifetime_no_size() sanitize_address {
entry: entry:
%i = alloca i32, align 4 %i = alloca i32, align 4
%i.ptr = bitcast i32* %i to i8* %i.ptr = bitcast i32* %i to i8*
@@ -23,7 +23,7 @@ entry:
} }
; Generic case of lifetime analysis. ; Generic case of lifetime analysis.
define void @lifetime() address_safety { define void @lifetime() sanitize_address {
; CHECK: @lifetime ; CHECK: @lifetime
; Regular variable lifetime intrinsics. ; Regular variable lifetime intrinsics.
@@ -61,7 +61,7 @@ define void @lifetime() address_safety {
} }
; Check that arguments of lifetime may come from phi nodes. ; Check that arguments of lifetime may come from phi nodes.
define void @phi_args(i1 %x) address_safety { define void @phi_args(i1 %x) sanitize_address {
; CHECK: @phi_args ; CHECK: @phi_args
entry: entry:

View File

@@ -1,7 +1,7 @@
; RUN: opt < %s -asan -S | FileCheck %s ; RUN: opt < %s -asan -S | FileCheck %s
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
target triple = "x86_64-unknown-linux-gnu" target triple = "x86_64-unknown-linux-gnu"
define i32 @read_4_bytes(i32* %a) address_safety { define i32 @read_4_bytes(i32* %a) sanitize_address {
entry: entry:
%tmp1 = load i32* %a, align 4 %tmp1 = load i32* %a, align 4
ret i32 %tmp1 ret i32 %tmp1
@@ -13,7 +13,7 @@ entry:
; CHECK-NEXT: {{17592186044416|2147450880}} ; CHECK-NEXT: {{17592186044416|2147450880}}
; CHECK: ret ; CHECK: ret
define void @example_atomicrmw(i64* %ptr) nounwind uwtable address_safety { define void @example_atomicrmw(i64* %ptr) nounwind uwtable sanitize_address {
entry: entry:
%0 = atomicrmw add i64* %ptr, i64 1 seq_cst %0 = atomicrmw add i64* %ptr, i64 1 seq_cst
ret void ret void
@@ -24,7 +24,7 @@ entry:
; CHECK: atomicrmw ; CHECK: atomicrmw
; CHECK: ret ; CHECK: ret
define void @example_cmpxchg(i64* %ptr, i64 %compare_to, i64 %new_value) nounwind uwtable address_safety { define void @example_cmpxchg(i64* %ptr, i64 %compare_to, i64 %new_value) nounwind uwtable sanitize_address {
entry: entry:
%0 = cmpxchg i64* %ptr, i64 %compare_to, i64 %new_value seq_cst %0 = cmpxchg i64* %ptr, i64 %compare_to, i64 %new_value seq_cst
ret void ret void

View File

@@ -8,9 +8,9 @@ target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f3
@f = global %struct_of_8_bytes_4_aligned zeroinitializer, align 4 @f = global %struct_of_8_bytes_4_aligned zeroinitializer, align 4
; Accessing bytes 4 and 6, not ok to widen to i32 if thread_safety is set. ; Accessing bytes 4 and 6, not ok to widen to i32 if sanitize_thread is set.
define i32 @test_widening_bad(i8* %P) nounwind ssp noredzone thread_safety { define i32 @test_widening_bad(i8* %P) nounwind ssp noredzone sanitize_thread {
entry: entry:
%tmp = load i8* getelementptr inbounds (%struct_of_8_bytes_4_aligned* @f, i64 0, i32 1), align 4 %tmp = load i8* getelementptr inbounds (%struct_of_8_bytes_4_aligned* @f, i64 0, i32 1), align 4
%conv = zext i8 %tmp to i32 %conv = zext i8 %tmp to i32

View File

@@ -174,9 +174,9 @@ FuncAttr ::= noreturn
| sspreq | sspreq
| returns_twice | returns_twice
| nonlazybind | nonlazybind
| address_safety | sanitize_address
| thread_safety | sanitize_thread
| uninitialized_checks | sanitize_memory
; ;
OptFuncAttrs ::= + _ | OptFuncAttrs FuncAttr ; OptFuncAttrs ::= + _ | OptFuncAttrs FuncAttr ;

View File

@@ -35,7 +35,7 @@ syn keyword llvmStatement uitofp ule ult umax umin une uno unreachable unwind
syn keyword llvmStatement urem va_arg xchg xor zext syn keyword llvmStatement urem va_arg xchg xor zext
" Keywords. " Keywords.
syn keyword llvmKeyword acq_rel acquire address_safety addrspace alias align syn keyword llvmKeyword acq_rel acquire sanitize_address addrspace alias align
syn keyword llvmKeyword alignstack alwaysinline appending arm_aapcs_vfpcc syn keyword llvmKeyword alignstack alwaysinline appending arm_aapcs_vfpcc
syn keyword llvmKeyword arm_aapcscc arm_apcscc asm atomic available_externally syn keyword llvmKeyword arm_aapcscc arm_apcscc asm atomic available_externally
syn keyword llvmKeyword blockaddress byval c catch cc ccc cleanup coldcc common syn keyword llvmKeyword blockaddress byval c catch cc ccc cleanup coldcc common
@@ -55,7 +55,7 @@ syn keyword llvmKeyword singlethread spir_func spir_kernel sret ssp sspreq
syn keyword llvmKeyword sspstrong tail target thread_local to triple syn keyword llvmKeyword sspstrong tail target thread_local to triple
syn keyword llvmKeyword unnamed_addr unordered uwtable volatile weak weak_odr syn keyword llvmKeyword unnamed_addr unordered uwtable volatile weak weak_odr
syn keyword llvmKeyword x86_fastcallcc x86_stdcallcc x86_thiscallcc zeroext syn keyword llvmKeyword x86_fastcallcc x86_stdcallcc x86_thiscallcc zeroext
syn keyword llvmKeyword thread_safety uninitialized_checks syn keyword llvmKeyword sanitize_thread sanitize_memory
" Obsolete keywords. " Obsolete keywords.
syn keyword llvmError getresult begin end syn keyword llvmError getresult begin end