llvm.org GIT mirror llvm / 8eec41f
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 Kostya Serebryany 6 years ago
25 changed file(s) with 127 addition(s) and 127 deletion(s). Raw diff Collapse all Expand all
792792 define void @f() alwaysinline optsize { ... }
793793 define void @f() optsize { ... }
794794
795 ``address_safety``
796 This attribute indicates that the address safety analysis is enabled
797 for this function.
798795 ``alignstack()``
799796 This attribute indicates that, when emitting the prologue and
800797 epilogue, the backend should forcibly align the stack pointer.
872869 ``setjmp`` is an example of such a function. The compiler disables
873870 some optimizations (like tail calls) in the caller of these
874871 functions.
872 ``sanitize_address``
873 This attribute indicates that AddressSanitizer checks
874 (dynamic address safety analysis) are enabled for this function.
875 ``sanitize_memory``
876 This attribute indicates that MemorySanitizer checks (dynamic detection
877 of accesses to uninitialized memory) are enabled for this function.
878 ``sanitize_thread``
879 This attribute indicates that ThreadSanitizer checks
880 (dynamic thread safety analysis) are enabled for this function.
875881 ``ssp``
876882 This attribute indicates that the function should emit a stack
877883 smashing protector. It is in the form of a "canary" --- a random value
913919 If a function that has an ``sspstrong`` attribute is inlined into a
914920 function that doesn't have an ``sspstrong`` attribute, then the
915921 resulting function will have an ``sspstrong`` attribute.
916 ``thread_safety``
917 This attribute indicates that the thread safety analysis is enabled
918 for this function.
919 ``uninitialized_checks``
920 This attribute indicates that the checks for uses of uninitialized
921 memory are enabled.
922922 ``uwtable``
923923 This attribute indicates that the ABI being targeted requires that
924924 an unwind table entry be produce for this function even if we can
6262 enum AttrKind {
6363 // IR-Level Attributes
6464 None, ///< No attributes have been set
65 AddressSafety, ///< Address safety checking is on.
6665 Alignment, ///< Alignment of parameter (5 bits)
6766 ///< stored as log2 of alignment with +1 bias
6867 ///< 0 means unaligned (different from align(1))
9796 StackProtectReq, ///< Stack protection required.
9897 StackProtectStrong, ///< Strong Stack protection.
9998 StructRet, ///< Hidden pointer to structure to return
100 ThreadSafety, ///< Thread safety checking is on.
101 UninitializedChecks, ///< Checking for uses of uninitialized memory is on.
99 SanitizeAddress, ///< AddressSanitizer is on.
100 SanitizeThread, ///< ThreadSanitizer is on.
101 SanitizeMemory, ///< MemorySanitizer is on.
102102 UWTable, ///< Function must be in a unwind table
103103 ZExt, ///< Zero extended before/after call
104104
286286 // Load widening is hostile to ThreadSanitizer: it may cause false positives
287287 // or make the reports more cryptic (access sizes are wrong).
288288 if (LI->getParent()->getParent()->getAttributes().
289 hasAttribute(AttributeSet::FunctionIndex, Attribute::ThreadSafety))
289 hasAttribute(AttributeSet::FunctionIndex, Attribute::SanitizeThread))
290290 return 0;
291291
292292 // Get the base of this load.
333333
334334 if (LIOffs+NewLoadByteSize > MemLocEnd &&
335335 LI->getParent()->getParent()->getAttributes().
336 hasAttribute(AttributeSet::FunctionIndex, Attribute::AddressSafety))
336 hasAttribute(AttributeSet::FunctionIndex, Attribute::SanitizeAddress))
337337 // We will be reading past the location accessed by the original program.
338338 // While this is safe in a regular build, Address Safety analysis tools
339339 // may start reporting false warnings. So, don't do widening.
561561
562562 KEYWORD(attributes);
563563
564 KEYWORD(address_safety);
565564 KEYWORD(alwaysinline);
566565 KEYWORD(byval);
567566 KEYWORD(inlinehint);
588587 KEYWORD(ssp);
589588 KEYWORD(sspreq);
590589 KEYWORD(sspstrong);
591 KEYWORD(thread_safety);
592 KEYWORD(uninitialized_checks);
590 KEYWORD(sanitize_address);
591 KEYWORD(sanitize_thread);
592 KEYWORD(sanitize_memory);
593593 KEYWORD(uwtable);
594594 KEYWORD(zeroext);
595595
906906 B.addStackAlignmentAttr(Alignment);
907907 continue;
908908 }
909 case lltok::kw_address_safety: B.addAttribute(Attribute::AddressSafety); break;
910 case lltok::kw_alwaysinline: B.addAttribute(Attribute::AlwaysInline); break;
911 case lltok::kw_inlinehint: B.addAttribute(Attribute::InlineHint); break;
912 case lltok::kw_minsize: B.addAttribute(Attribute::MinSize); break;
913 case lltok::kw_naked: B.addAttribute(Attribute::Naked); break;
914 case lltok::kw_nobuiltin: B.addAttribute(Attribute::NoBuiltin); break;
915 case lltok::kw_noduplicate: B.addAttribute(Attribute::NoDuplicate); break;
916 case lltok::kw_noimplicitfloat: B.addAttribute(Attribute::NoImplicitFloat); break;
917 case lltok::kw_noinline: B.addAttribute(Attribute::NoInline); break;
918 case lltok::kw_nonlazybind: B.addAttribute(Attribute::NonLazyBind); break;
919 case lltok::kw_noredzone: B.addAttribute(Attribute::NoRedZone); break;
920 case lltok::kw_noreturn: B.addAttribute(Attribute::NoReturn); break;
921 case lltok::kw_nounwind: B.addAttribute(Attribute::NoUnwind); break;
922 case lltok::kw_optsize: B.addAttribute(Attribute::OptimizeForSize); break;
923 case lltok::kw_readnone: B.addAttribute(Attribute::ReadNone); break;
924 case lltok::kw_readonly: B.addAttribute(Attribute::ReadOnly); break;
925 case lltok::kw_returns_twice: B.addAttribute(Attribute::ReturnsTwice); break;
926 case lltok::kw_ssp: B.addAttribute(Attribute::StackProtect); break;
927 case lltok::kw_sspreq: B.addAttribute(Attribute::StackProtectReq); break;
928 case lltok::kw_sspstrong: B.addAttribute(Attribute::StackProtectStrong); break;
929 case lltok::kw_thread_safety: B.addAttribute(Attribute::ThreadSafety); break;
930 case lltok::kw_uninitialized_checks: B.addAttribute(Attribute::UninitializedChecks); break;
931 case lltok::kw_uwtable: B.addAttribute(Attribute::UWTable); break;
909 case lltok::kw_alwaysinline: B.addAttribute(Attribute::AlwaysInline); break;
910 case lltok::kw_inlinehint: B.addAttribute(Attribute::InlineHint); break;
911 case lltok::kw_minsize: B.addAttribute(Attribute::MinSize); break;
912 case lltok::kw_naked: B.addAttribute(Attribute::Naked); break;
913 case lltok::kw_nobuiltin: B.addAttribute(Attribute::NoBuiltin); break;
914 case lltok::kw_noduplicate: B.addAttribute(Attribute::NoDuplicate); break;
915 case lltok::kw_noimplicitfloat: B.addAttribute(Attribute::NoImplicitFloat); break;
916 case lltok::kw_noinline: B.addAttribute(Attribute::NoInline); break;
917 case lltok::kw_nonlazybind: B.addAttribute(Attribute::NonLazyBind); break;
918 case lltok::kw_noredzone: B.addAttribute(Attribute::NoRedZone); break;
919 case lltok::kw_noreturn: B.addAttribute(Attribute::NoReturn); break;
920 case lltok::kw_nounwind: B.addAttribute(Attribute::NoUnwind); break;
921 case lltok::kw_optsize: B.addAttribute(Attribute::OptimizeForSize); break;
922 case lltok::kw_readnone: B.addAttribute(Attribute::ReadNone); break;
923 case lltok::kw_readonly: B.addAttribute(Attribute::ReadOnly); break;
924 case lltok::kw_returns_twice: B.addAttribute(Attribute::ReturnsTwice); break;
925 case lltok::kw_ssp: B.addAttribute(Attribute::StackProtect); break;
926 case lltok::kw_sspreq: B.addAttribute(Attribute::StackProtectReq); break;
927 case lltok::kw_sspstrong: B.addAttribute(Attribute::StackProtectStrong); break;
928 case lltok::kw_sanitize_address: B.addAttribute(Attribute::SanitizeAddress); break;
929 case lltok::kw_sanitize_thread: B.addAttribute(Attribute::SanitizeThread); break;
930 case lltok::kw_sanitize_memory: B.addAttribute(Attribute::SanitizeMemory); break;
931 case lltok::kw_uwtable: B.addAttribute(Attribute::UWTable); break;
932932
933933 // Error handling.
934934 case lltok::kw_inreg:
11581158 case lltok::kw_sret: B.addAttribute(Attribute::StructRet); break;
11591159 case lltok::kw_zeroext: B.addAttribute(Attribute::ZExt); break;
11601160
1161 case lltok::kw_noreturn: case lltok::kw_nounwind:
1162 case lltok::kw_uwtable: case lltok::kw_returns_twice:
1163 case lltok::kw_noinline: case lltok::kw_readnone:
1164 case lltok::kw_readonly: case lltok::kw_inlinehint:
1165 case lltok::kw_alwaysinline: case lltok::kw_optsize:
1166 case lltok::kw_ssp: case lltok::kw_sspreq:
1167 case lltok::kw_noredzone: case lltok::kw_noimplicitfloat:
1168 case lltok::kw_naked: case lltok::kw_nonlazybind:
1169 case lltok::kw_address_safety: case lltok::kw_minsize:
1170 case lltok::kw_alignstack: case lltok::kw_thread_safety:
1171 case lltok::kw_nobuiltin: case lltok::kw_uninitialized_checks:
1161 case lltok::kw_alignstack: case lltok::kw_nounwind:
1162 case lltok::kw_alwaysinline: case lltok::kw_optsize:
1163 case lltok::kw_inlinehint: case lltok::kw_readnone:
1164 case lltok::kw_minsize: case lltok::kw_readonly:
1165 case lltok::kw_naked: case lltok::kw_returns_twice:
1166 case lltok::kw_nobuiltin: case lltok::kw_sanitize_address:
1167 case lltok::kw_noimplicitfloat: case lltok::kw_sanitize_memory:
1168 case lltok::kw_noinline: case lltok::kw_sanitize_thread:
1169 case lltok::kw_nonlazybind: case lltok::kw_ssp:
1170 case lltok::kw_noredzone: case lltok::kw_sspreq:
1171 case lltok::kw_noreturn: case lltok::kw_uwtable:
11721172 HaveError |= Error(Lex.getLoc(), "invalid use of function-only attribute");
11731173 break;
11741174 }
11991199 HaveError |= Error(Lex.getLoc(), "invalid use of parameter-only attribute");
12001200 break;
12011201
1202 case lltok::kw_noreturn: case lltok::kw_nounwind:
1203 case lltok::kw_uwtable: case lltok::kw_returns_twice:
1204 case lltok::kw_noinline: case lltok::kw_readnone:
1205 case lltok::kw_readonly: case lltok::kw_inlinehint:
1206 case lltok::kw_alwaysinline: case lltok::kw_optsize:
1207 case lltok::kw_ssp: case lltok::kw_sspreq:
1208 case lltok::kw_sspstrong: case lltok::kw_noimplicitfloat:
1209 case lltok::kw_noredzone: case lltok::kw_naked:
1210 case lltok::kw_nonlazybind: case lltok::kw_address_safety:
1211 case lltok::kw_minsize: case lltok::kw_alignstack:
1212 case lltok::kw_align: case lltok::kw_noduplicate:
1213 case lltok::kw_thread_safety: case lltok::kw_uninitialized_checks:
1214 case lltok::kw_nobuiltin:
1202 case lltok::kw_align: case lltok::kw_noreturn:
1203 case lltok::kw_alignstack: case lltok::kw_nounwind:
1204 case lltok::kw_alwaysinline: case lltok::kw_optsize:
1205 case lltok::kw_inlinehint: case lltok::kw_readnone:
1206 case lltok::kw_minsize: case lltok::kw_readonly:
1207 case lltok::kw_naked: case lltok::kw_returns_twice:
1208 case lltok::kw_nobuiltin: case lltok::kw_sanitize_address:
1209 case lltok::kw_noduplicate: case lltok::kw_sanitize_memory:
1210 case lltok::kw_noimplicitfloat: case lltok::kw_sanitize_thread:
1211 case lltok::kw_noinline: case lltok::kw_ssp:
1212 case lltok::kw_nonlazybind: case lltok::kw_sspreq:
1213 case lltok::kw_noredzone: case lltok::kw_sspstrong:
1214 case lltok::kw_uwtable:
12151215 HaveError |= Error(Lex.getLoc(), "invalid use of function-only attribute");
12161216 break;
12171217 }
9393 // Attributes:
9494 kw_attributes,
9595 kw_alwaysinline,
96 kw_address_safety,
96 kw_sanitize_address,
9797 kw_byval,
9898 kw_inlinehint,
9999 kw_inreg,
119119 kw_sspreq,
120120 kw_sspstrong,
121121 kw_sret,
122 kw_thread_safety,
123 kw_uninitialized_checks,
122 kw_sanitize_thread,
123 kw_sanitize_memory,
124124 kw_uwtable,
125125 kw_zeroext,
126126
152152 std::string Attribute::getAsString(bool InAttrGrp) const {
153153 if (!pImpl) return "";
154154
155 if (hasAttribute(Attribute::AddressSafety))
156 return "address_safety";
155 if (hasAttribute(Attribute::SanitizeAddress))
156 return "sanitize_address";
157157 if (hasAttribute(Attribute::AlwaysInline))
158158 return "alwaysinline";
159159 if (hasAttribute(Attribute::ByVal))
206206 return "sspstrong";
207207 if (hasAttribute(Attribute::StructRet))
208208 return "sret";
209 if (hasAttribute(Attribute::ThreadSafety))
210 return "thread_safety";
211 if (hasAttribute(Attribute::UninitializedChecks))
212 return "uninitialized_checks";
209 if (hasAttribute(Attribute::SanitizeThread))
210 return "sanitize_thread";
211 if (hasAttribute(Attribute::SanitizeMemory))
212 return "sanitize_memory";
213213 if (hasAttribute(Attribute::UWTable))
214214 return "uwtable";
215215 if (hasAttribute(Attribute::ZExt))
385385 case Attribute::ReturnsTwice: return 1 << 29;
386386 case Attribute::UWTable: return 1 << 30;
387387 case Attribute::NonLazyBind: return 1U << 31;
388 case Attribute::AddressSafety: return 1ULL << 32;
388 case Attribute::SanitizeAddress: return 1ULL << 32;
389389 case Attribute::MinSize: return 1ULL << 33;
390390 case Attribute::NoDuplicate: return 1ULL << 34;
391391 case Attribute::StackProtectStrong: return 1ULL << 35;
392 case Attribute::ThreadSafety: return 1ULL << 36;
393 case Attribute::UninitializedChecks: return 1ULL << 37;
392 case Attribute::SanitizeThread: return 1ULL << 36;
393 case Attribute::SanitizeMemory: return 1ULL << 37;
394394 case Attribute::NoBuiltin: return 1ULL << 38;
395395 }
396396 llvm_unreachable("Unsupported attribute type");
11181118 .removeAttribute(Attribute::UWTable)
11191119 .removeAttribute(Attribute::NonLazyBind)
11201120 .removeAttribute(Attribute::ReturnsTwice)
1121 .removeAttribute(Attribute::AddressSafety)
1122 .removeAttribute(Attribute::ThreadSafety)
1123 .removeAttribute(Attribute::UninitializedChecks)
1121 .removeAttribute(Attribute::SanitizeAddress)
1122 .removeAttribute(Attribute::SanitizeThread)
1123 .removeAttribute(Attribute::SanitizeMemory)
11241124 .removeAttribute(Attribute::MinSize)
11251125 .removeAttribute(Attribute::NoDuplicate)
11261126 .removeAttribute(Attribute::NoBuiltin);
649649 !Attrs.hasAttribute(Idx, Attribute::UWTable) &&
650650 !Attrs.hasAttribute(Idx, Attribute::NonLazyBind) &&
651651 !Attrs.hasAttribute(Idx, Attribute::ReturnsTwice) &&
652 !Attrs.hasAttribute(Idx, Attribute::AddressSafety) &&
653 !Attrs.hasAttribute(Idx, Attribute::ThreadSafety) &&
654 !Attrs.hasAttribute(Idx, Attribute::UninitializedChecks) &&
652 !Attrs.hasAttribute(Idx, Attribute::SanitizeAddress) &&
653 !Attrs.hasAttribute(Idx, Attribute::SanitizeThread) &&
654 !Attrs.hasAttribute(Idx, Attribute::SanitizeMemory) &&
655655 !Attrs.hasAttribute(Idx, Attribute::MinSize) &&
656656 !Attrs.hasAttribute(Idx, Attribute::NoBuiltin),
657657 "Some attributes in '" + Attrs.getAsString(Idx) +
10971097 DEBUG(dbgs() << "ASAN instrumenting:\n" << F << "\n");
10981098 initializeCallbacks(*F.getParent());
10991099
1100 // If needed, insert __asan_init before checking for AddressSafety attr.
1100 // If needed, insert __asan_init before checking for SanitizeAddress attr.
11011101 maybeInsertAsanInitAtFunctionEntry(F);
11021102
11031103 if (!F.getAttributes().hasAttribute(AttributeSet::FunctionIndex,
1104 Attribute::AddressSafety))
1104 Attribute::SanitizeAddress))
11051105 return false;
11061106
11071107 if (!ClDebugFunc.empty() && ClDebugFunc != F.getName())
156156 ret void;
157157 }
158158
159 define void @f27() address_safety
159 define void @f27() sanitize_address
160160 ; CHECK: define void @f27() #17
161161 {
162162 ret void;
163163 }
164 define void @f28() thread_safety
164 define void @f28() sanitize_thread
165165 ; CHECK: define void @f28() #18
166166 {
167167 ret void;
168168 }
169 define void @f29() uninitialized_checks
169 define void @f29() sanitize_memory
170170 ; CHECK: define void @f29() #19
171171 {
172172 ret void;
195195 ; CHECK: attributes #14 = { returns_twice }
196196 ; CHECK: attributes #15 = { uwtable }
197197 ; CHECK: attributes #16 = { nonlazybind }
198 ; CHECK: attributes #17 = { address_safety }
199 ; CHECK: attributes #18 = { thread_safety }
200 ; CHECK: attributes #19 = { uninitialized_checks }
198 ; CHECK: attributes #17 = { sanitize_address }
199 ; CHECK: attributes #18 = { sanitize_thread }
200 ; CHECK: attributes #19 = { sanitize_memory }
201201 ; CHECK: attributes #20 = { "cpu"="cortex-a8" }
430430 ; uitofp expands to an FCMOV instruction which splits the basic block.
431431 ; Make sure the live range of %AL isn't split.
432432 @.str = private unnamed_addr constant { [1 x i8], [63 x i8] } zeroinitializer, align 32
433 define void @pr13188(i64* nocapture %this) uwtable ssp address_safety align 2 {
433 define void @pr13188(i64* nocapture %this) uwtable ssp sanitize_address align 2 {
434434 entry:
435435 %x7 = load i64* %this, align 8
436436 %sub = add i64 %x7, -1
3535 @ff_mlp_firorder_7 = external global i8
3636 @ff_mlp_firorder_8 = external global i8
3737
38 define void @ff_mlp_init_x86(%struct.DSPContext* nocapture %c, %struct.AVCodecContext* nocapture %avctx) nounwind address_safety {
38 define void @ff_mlp_init_x86(%struct.DSPContext* nocapture %c, %struct.AVCodecContext* nocapture %avctx) nounwind sanitize_address {
3939 entry:
4040 %mlp_filter_channel = getelementptr inbounds %struct.DSPContext* %c, i32 0, i32 131
4141 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
4242 ret void
4343 }
4444
45 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 {
45 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 {
4646 entry:
4747 %filter_shift.addr = alloca i32, align 4
4848 %mask.addr = alloca i32, align 4
1010
1111 @f = global %struct_of_7_bytes_4_aligned zeroinitializer, align 4
1212
13 ; Accessing bytes 4 and 6, not ok to widen to i32 if address_safety is set.
13 ; Accessing bytes 4 and 6, not ok to widen to i32 if sanitize_address is set.
1414
15 define i32 @test_widening_bad(i8* %P) nounwind ssp noredzone address_safety {
15 define i32 @test_widening_bad(i8* %P) nounwind ssp noredzone sanitize_address {
1616 entry:
1717 %tmp = load i8* getelementptr inbounds (%struct_of_7_bytes_4_aligned* @f, i64 0, i32 1), align 4
1818 %conv = zext i8 %tmp to i32
3535
3636 ;; Accessing bytes 4 and 5. Ok to widen to i16.
3737
38 define i32 @test_widening_ok(i8* %P) nounwind ssp noredzone address_safety {
38 define i32 @test_widening_ok(i8* %P) nounwind ssp noredzone sanitize_address {
3939 entry:
4040 %tmp = load i8* getelementptr inbounds (%struct_of_7_bytes_4_aligned* @f, i64 0, i32 1), align 4
4141 %conv = zext i8 %tmp to i32
44 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"
55 target triple = "x86_64-unknown-linux-gnu"
66
7 define i32 @test_load(i32* %a) address_safety {
7 define i32 @test_load(i32* %a) sanitize_address {
88 ; CHECK: @test_load
99 ; CHECK-NOT: load
1010 ; CHECK: %[[LOAD_ADDR:[^ ]*]] = ptrtoint i32* %a to i64
3737 ret i32 %tmp1
3838 }
3939
40 define void @test_store(i32* %a) address_safety {
40 define void @test_store(i32* %a) sanitize_address {
4141 ; CHECK: @test_store
4242 ; CHECK-NOT: store
4343 ; CHECK: %[[STORE_ADDR:[^ ]*]] = ptrtoint i32* %a to i64
7272 ; Check that asan leaves just one alloca.
7373
7474 declare void @alloca_test_use([10 x i8]*)
75 define void @alloca_test() address_safety {
75 define void @alloca_test() sanitize_address {
7676 entry:
7777 %x = alloca [10 x i8], align 1
7878 %y = alloca [10 x i8], align 1
8888 ; CHECK-NOT: = alloca
8989 ; CHECK: ret void
9090
91 define void @LongDoubleTest(x86_fp80* nocapture %a) nounwind uwtable address_safety {
91 define void @LongDoubleTest(x86_fp80* nocapture %a) nounwind uwtable sanitize_address {
9292 entry:
9393 store x86_fp80 0xK3FFF8000000000000000, x86_fp80* %a, align 16
9494 ret void
100100 ; CHECK: ret void
101101
102102
103 define void @i40test(i40* %a, i40* %b) nounwind uwtable address_safety {
103 define void @i40test(i40* %a, i40* %b) nounwind uwtable sanitize_address {
104104 entry:
105105 %t = load i40* %a
106106 store i40 %t, i40* %b, align 8
114114 ; CHECK: __asan_report_store_n{{.*}}, i64 5)
115115 ; CHECK: ret void
116116
117 define void @i80test(i80* %a, i80* %b) nounwind uwtable address_safety {
117 define void @i80test(i80* %a, i80* %b) nounwind uwtable sanitize_address {
118118 entry:
119119 %t = load i80* %a
120120 store i80 %t, i80* %b, align 8
55 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"
66 target triple = "x86_64-unknown-linux-gnu"
77
8 define i32 @_Z3zzzi(i32 %p) nounwind uwtable address_safety {
8 define i32 @_Z3zzzi(i32 %p) nounwind uwtable sanitize_address {
99 entry:
1010 %p.addr = alloca i32, align 4
1111 %r = alloca i32, align 4
88 ; CHECK: @__asan_mapping_offset = linkonce_odr constant i64 0
99 ; CHECK: @__asan_mapping_scale = linkonce_odr constant i64 2
1010
11 define i32 @test_load(i32* %a) address_safety {
11 define i32 @test_load(i32* %a) sanitize_address {
1212 ; CHECK: @test_load
1313 ; CHECK-NOT: load
1414 ; CHECK: %[[LOAD_ADDR:[^ ]*]] = ptrtoint i32* %a to i64
44 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"
55 target triple = "x86_64-unknown-linux-gnu"
66
7 define void @_Z3barv() uwtable address_safety {
7 define void @_Z3barv() uwtable sanitize_address {
88 entry:
99 %a = alloca i32, align 4
1010 call void @_Z3fooPi(i32* %a)
66
77 declare void @MyNoReturnFunc(i32) noreturn
88
9 define i32 @Call1(i8* nocapture %arg) uwtable address_safety {
9 define i32 @Call1(i8* nocapture %arg) uwtable sanitize_address {
1010 entry:
1111 call void @MyNoReturnFunc(i32 1) noreturn ; The call insn has noreturn attr.
1212 ; CHECK: @Call1
1616 unreachable
1717 }
1818
19 define i32 @Call2(i8* nocapture %arg) uwtable address_safety {
19 define i32 @Call2(i8* nocapture %arg) uwtable sanitize_address {
2020 entry:
2121 call void @MyNoReturnFunc(i32 1) ; No noreturn attribure on the call.
2222 ; CHECK: @Call2
2828
2929 declare i32 @__gxx_personality_v0(...)
3030
31 define i64 @Invoke1(i8** %esc) nounwind uwtable ssp address_safety {
31 define i64 @Invoke1(i8** %esc) nounwind uwtable ssp sanitize_address {
3232 entry:
3333 invoke void @MyNoReturnFunc(i32 1)
3434 to label %invoke.cont unwind label %lpad
2222 ret void
2323 }
2424
25 define internal void @_GLOBAL__I_a() address_safety section ".text.startup" {
25 define internal void @_GLOBAL__I_a() sanitize_address section ".text.startup" {
2626 entry:
2727 call void @__cxx_global_var_init()
2828 ret void
3939 ; CHECK: ret
4040
4141 ; Check that xxx is instrumented.
42 define void @touch_xxx() address_safety {
42 define void @touch_xxx() sanitize_address {
4343 store i32 0, i32 *@xxx, align 4
4444 ret void
4545 ; CHECK: define void @touch_xxx
4848 }
4949
5050 ; Check that XXX is instrumented.
51 define void @touch_XXX() address_safety {
51 define void @touch_XXX() sanitize_address {
5252 store i32 0, i32 *@XXX, align 4
5353 ret void
5454 ; CHECK: define void @touch_XXX
5858
5959
6060 ; Check that yyy is NOT instrumented (as it does not have dynamic initializer).
61 define void @touch_yyy() address_safety {
61 define void @touch_yyy() sanitize_address {
6262 store i32 0, i32 *@yyy, align 4
6363 ret void
6464 ; CHECK: define void @touch_yyy
6767 }
6868
6969 ; Check that YYY is NOT instrumented (as it does not have dynamic initializer).
70 define void @touch_YYY() address_safety {
70 define void @touch_YYY() sanitize_address {
7171 store i32 0, i32 *@YYY, align 4
7272 ret void
7373 ; CHECK: define void @touch_YYY
33
44 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"
55 target triple = "x86_64-unknown-linux-gnu"
6 define void @IncrementMe(i32* %a) address_safety {
6 define void @IncrementMe(i32* %a) sanitize_address {
77 entry:
88 %tmp1 = load i32* %a, align 4
99 %tmp2 = add i32 %tmp1, 1
66 declare void @llvm.lifetime.start(i64, i8* nocapture) nounwind
77 declare void @llvm.lifetime.end(i64, i8* nocapture) nounwind
88
9 define void @lifetime_no_size() address_safety {
9 define void @lifetime_no_size() sanitize_address {
1010 entry:
1111 %i = alloca i32, align 4
1212 %i.ptr = bitcast i32* %i to i8*
2222 }
2323
2424 ; Generic case of lifetime analysis.
25 define void @lifetime() address_safety {
25 define void @lifetime() sanitize_address {
2626 ; CHECK: @lifetime
2727
2828 ; Regular variable lifetime intrinsics.
6060 }
6161
6262 ; Check that arguments of lifetime may come from phi nodes.
63 define void @phi_args(i1 %x) address_safety {
63 define void @phi_args(i1 %x) sanitize_address {
6464 ; CHECK: @phi_args
6565
6666 entry:
0 ; RUN: opt < %s -asan -S | FileCheck %s
11 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"
22 target triple = "x86_64-unknown-linux-gnu"
3 define i32 @read_4_bytes(i32* %a) address_safety {
3 define i32 @read_4_bytes(i32* %a) sanitize_address {
44 entry:
55 %tmp1 = load i32* %a, align 4
66 ret i32 %tmp1
1212 ; CHECK-NEXT: {{17592186044416|2147450880}}
1313 ; CHECK: ret
1414
15 define void @example_atomicrmw(i64* %ptr) nounwind uwtable address_safety {
15 define void @example_atomicrmw(i64* %ptr) nounwind uwtable sanitize_address {
1616 entry:
1717 %0 = atomicrmw add i64* %ptr, i64 1 seq_cst
1818 ret void
2323 ; CHECK: atomicrmw
2424 ; CHECK: ret
2525
26 define void @example_cmpxchg(i64* %ptr, i64 %compare_to, i64 %new_value) nounwind uwtable address_safety {
26 define void @example_cmpxchg(i64* %ptr, i64 %compare_to, i64 %new_value) nounwind uwtable sanitize_address {
2727 entry:
2828 %0 = cmpxchg i64* %ptr, i64 %compare_to, i64 %new_value seq_cst
2929 ret void
77
88 @f = global %struct_of_8_bytes_4_aligned zeroinitializer, align 4
99
10 ; Accessing bytes 4 and 6, not ok to widen to i32 if thread_safety is set.
10 ; Accessing bytes 4 and 6, not ok to widen to i32 if sanitize_thread is set.
1111
12 define i32 @test_widening_bad(i8* %P) nounwind ssp noredzone thread_safety {
12 define i32 @test_widening_bad(i8* %P) nounwind ssp noredzone sanitize_thread {
1313 entry:
1414 %tmp = load i8* getelementptr inbounds (%struct_of_8_bytes_4_aligned* @f, i64 0, i32 1), align 4
1515 %conv = zext i8 %tmp to i32
173173 | sspreq
174174 | returns_twice
175175 | nonlazybind
176 | address_safety
177 | thread_safety
178 | uninitialized_checks
176 | sanitize_address
177 | sanitize_thread
178 | sanitize_memory
179179 ;
180180
181181 OptFuncAttrs ::= + _ | OptFuncAttrs FuncAttr ;
3434 syn keyword llvmStatement urem va_arg xchg xor zext
3535
3636 " Keywords.
37 syn keyword llvmKeyword acq_rel acquire address_safety addrspace alias align
37 syn keyword llvmKeyword acq_rel acquire sanitize_address addrspace alias align
3838 syn keyword llvmKeyword alignstack alwaysinline appending arm_aapcs_vfpcc
3939 syn keyword llvmKeyword arm_aapcscc arm_apcscc asm atomic available_externally
4040 syn keyword llvmKeyword blockaddress byval c catch cc ccc cleanup coldcc common
5454 syn keyword llvmKeyword sspstrong tail target thread_local to triple
5555 syn keyword llvmKeyword unnamed_addr unordered uwtable volatile weak weak_odr
5656 syn keyword llvmKeyword x86_fastcallcc x86_stdcallcc x86_thiscallcc zeroext
57 syn keyword llvmKeyword thread_safety uninitialized_checks
57 syn keyword llvmKeyword sanitize_thread sanitize_memory
5858
5959 " Obsolete keywords.
6060 syn keyword llvmError getresult begin end