Nikita Popov 92c55a315e
[IR] Only allow lifetime.start/end on allocas (#149310)
lifetime.start and lifetime.end are primarily intended for use on
allocas, to enable stack coloring and other liveness optimizations. This
is necessary because all (static) allocas are hoisted into the entry
block, so lifetime markers are the only way to convey the actual
lifetimes.

However, lifetime.start and lifetime.end are currently *allowed* to be
used on non-alloca pointers. We don't actually do this in practice, but
just the mere fact that this is possible breaks the core purpose of the
lifetime markers, which is stack coloring of allocas. Stack coloring can
only work correctly if all lifetime markers for an alloca are
analyzable.

* If a lifetime marker may operate on multiple allocas via a select/phi,
we don't know which lifetime actually starts/ends and handle it
incorrectly (https://github.com/llvm/llvm-project/issues/104776).
* Stack coloring operates on the assumption that all lifetime markers
are visible, and not, for example, hidden behind a function call or
escaped pointer. It's not possible to change this, as part of the
purpose of lifetime markers is that they work even in the presence of
escaped pointers, where simple use analysis is insufficient.

I don't think there is any way to have coherent semantics for lifetime
markers on allocas, while also permitting them on arbitrary pointer
values.

This PR restricts lifetimes to operate on allocas only. As a followup, I
will also drop the size argument, which is superfluous if we always
operate on an alloca. (This change also renders various code handling
lifetime markers on non-alloca dead. I plan to clean up that kind of
code after dropping the size argument as well.)

In practice, I've only found a few places that currently produce
lifetimes on non-allocas:

* CoroEarly replaces the promise alloca with the result of an intrinsic,
which will later be replaced back with an alloca. I think this is the
only place where there is some legitimate loss of functionality, but I
don't think this is particularly important (I don't think we'd expect
the promise in a coroutine to admit useful lifetime optimization.)
* SafeStack moves unsafe allocas onto a separate frame. We can safely
drop lifetimes here, as SafeStack performs its own stack coloring.
* Similar for AddressSanitizer, it also moves allocas into separate
memory.
* LSR sometimes replaces the lifetime argument with a GEP chain of the
alloca (where the offsets ultimately cancel out). This is just
unnecessary. (Fixed separately in
https://github.com/llvm/llvm-project/pull/149492.)
* InferAddrSpaces sometimes makes lifetimes operate on an addrspacecast
of an alloca. I don't think this is necessary.
2025-07-21 15:04:50 +02:00

575 lines
35 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
; Test appropriate tagging of funclet for function calls generated by asan.
; RUN: opt -S -passes=asan,win-eh-prepare -asan-use-stack-safety=0 -asan-max-inline-poisoning-size=0 -asan-detect-invalid-pointer-cmp -asan-detect-invalid-pointer-sub -asan-use-after-scope < %s | FileCheck %s --check-prefixes=CHECK,CHECK-INLINE
; RUN: opt -S -passes=asan,win-eh-prepare -asan-use-stack-safety=0 -asan-max-inline-poisoning-size=0 -asan-instrumentation-with-call-threshold=0 -asan-detect-invalid-pointer-cmp -asan-detect-invalid-pointer-sub -asan-use-after-scope < %s | FileCheck %s --check-prefixes=CHECK,CHECK-OUTLINE
; REQUIRES: x86-registered-target
target triple = "x86_64-pc-windows-msvc"
declare void @DeInit(ptr)
declare void @MayThrowFunc()
declare void @NoReturn() noreturn
declare void @llvm.memmove.p0.p0.i64(ptr nocapture, ptr nocapture readonly, i64, i1)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1)
declare void @llvm.lifetime.start.p0(i64, ptr nocapture) nounwind
declare void @llvm.lifetime.end.p0(i64, ptr nocapture) nounwind
declare i32 @__CxxFrameHandler3(...)
declare i32 @dummyPersonality(...)
define void @FuncletPersonality(ptr %ptrParam) sanitize_address personality ptr @__CxxFrameHandler3 {
; CHECK-INLINE-LABEL: define void @FuncletPersonality(
; CHECK-INLINE-SAME: ptr [[PTRPARAM:%.*]]) #[[ATTR3:[0-9]+]] personality ptr @__CxxFrameHandler3 {
; CHECK-INLINE-NEXT: entry:
; CHECK-INLINE-NEXT: [[TMP0:%.*]] = alloca i64, align 32
; CHECK-INLINE-NEXT: store i64 0, ptr [[TMP0]], align 8
; CHECK-INLINE-NEXT: [[TMP1:%.*]] = load i64, ptr @__asan_shadow_memory_dynamic_address, align 8
; CHECK-INLINE-NEXT: [[ASAN_LOCAL_STACK_BASE:%.*]] = alloca i64, align 8
; CHECK-INLINE-NEXT: [[TMP2:%.*]] = load i32, ptr @__asan_option_detect_stack_use_after_return, align 4
; CHECK-INLINE-NEXT: [[TMP3:%.*]] = icmp ne i32 [[TMP2]], 0
; CHECK-INLINE-NEXT: br i1 [[TMP3]], label [[TMP4:%.*]], label [[TMP6:%.*]]
; CHECK-INLINE: 4:
; CHECK-INLINE-NEXT: [[TMP5:%.*]] = call i64 @__asan_stack_malloc_8(i64 8544)
; CHECK-INLINE-NEXT: br label [[TMP6]]
; CHECK-INLINE: 6:
; CHECK-INLINE-NEXT: [[TMP7:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[TMP5]], [[TMP4]] ]
; CHECK-INLINE-NEXT: [[TMP8:%.*]] = icmp eq i64 [[TMP7]], 0
; CHECK-INLINE-NEXT: br i1 [[TMP8]], label [[TMP9:%.*]], label [[TMP11:%.*]]
; CHECK-INLINE: 9:
; CHECK-INLINE-NEXT: [[MYALLOCA:%.*]] = alloca i8, i64 8544, align 32
; CHECK-INLINE-NEXT: [[TMP10:%.*]] = ptrtoint ptr [[MYALLOCA]] to i64
; CHECK-INLINE-NEXT: br label [[TMP11]]
; CHECK-INLINE: 11:
; CHECK-INLINE-NEXT: [[TMP12:%.*]] = phi i64 [ [[TMP7]], [[TMP6]] ], [ [[TMP10]], [[TMP9]] ]
; CHECK-INLINE-NEXT: store i64 [[TMP12]], ptr [[ASAN_LOCAL_STACK_BASE]], align 8
; CHECK-INLINE-NEXT: [[TMP13:%.*]] = add i64 [[TMP12]], 32
; CHECK-INLINE-NEXT: [[TMP14:%.*]] = inttoptr i64 [[TMP13]] to ptr
; CHECK-INLINE-NEXT: [[TMP15:%.*]] = add i64 [[TMP12]], 8480
; CHECK-INLINE-NEXT: [[TMP16:%.*]] = inttoptr i64 [[TMP15]] to ptr
; CHECK-INLINE-NEXT: [[TMP17:%.*]] = add i64 [[TMP12]], 8496
; CHECK-INLINE-NEXT: [[TMP18:%.*]] = inttoptr i64 [[TMP17]] to ptr
; CHECK-INLINE-NEXT: [[TMP19:%.*]] = add i64 [[TMP12]], 8512
; CHECK-INLINE-NEXT: [[TMP20:%.*]] = inttoptr i64 [[TMP19]] to ptr
; CHECK-INLINE-NEXT: [[TMP21:%.*]] = add i64 [[TMP12]], 8528
; CHECK-INLINE-NEXT: [[TMP22:%.*]] = inttoptr i64 [[TMP21]] to ptr
; CHECK-INLINE-NEXT: [[TMP23:%.*]] = inttoptr i64 [[TMP12]] to ptr
; CHECK-INLINE-NEXT: store i64 1102416563, ptr [[TMP23]], align 8
; CHECK-INLINE-NEXT: [[TMP24:%.*]] = add i64 [[TMP12]], 8
; CHECK-INLINE-NEXT: [[TMP25:%.*]] = inttoptr i64 [[TMP24]] to ptr
; CHECK-INLINE-NEXT: store i64 ptrtoint (ptr @___asan_gen_stack to i64), ptr [[TMP25]], align 8
; CHECK-INLINE-NEXT: [[TMP26:%.*]] = add i64 [[TMP12]], 16
; CHECK-INLINE-NEXT: [[TMP27:%.*]] = inttoptr i64 [[TMP26]] to ptr
; CHECK-INLINE-NEXT: store i64 ptrtoint (ptr @FuncletPersonality to i64), ptr [[TMP27]], align 8
; CHECK-INLINE-NEXT: [[TMP28:%.*]] = lshr i64 [[TMP12]], 3
; CHECK-INLINE-NEXT: [[TMP29:%.*]] = add i64 [[TMP28]], [[TMP1]]
; CHECK-INLINE-NEXT: call void @__asan_set_shadow_f1(i64 [[TMP29]], i64 4)
; CHECK-INLINE-NEXT: [[TMP30:%.*]] = add i64 [[TMP29]], 1028
; CHECK-INLINE-NEXT: call void @__asan_set_shadow_f2(i64 [[TMP30]], i64 32)
; CHECK-INLINE-NEXT: [[TMP31:%.*]] = add i64 [[TMP29]], 1060
; CHECK-INLINE-NEXT: call void @__asan_set_shadow_04(i64 [[TMP31]], i64 1)
; CHECK-INLINE-NEXT: [[TMP32:%.*]] = add i64 [[TMP29]], 1061
; CHECK-INLINE-NEXT: call void @__asan_set_shadow_f2(i64 [[TMP32]], i64 1)
; CHECK-INLINE-NEXT: [[TMP33:%.*]] = add i64 [[TMP29]], 1062
; CHECK-INLINE-NEXT: call void @__asan_set_shadow_04(i64 [[TMP33]], i64 1)
; CHECK-INLINE-NEXT: [[TMP34:%.*]] = add i64 [[TMP29]], 1063
; CHECK-INLINE-NEXT: call void @__asan_set_shadow_f2(i64 [[TMP34]], i64 1)
; CHECK-INLINE-NEXT: [[TMP35:%.*]] = add i64 [[TMP29]], 1064
; CHECK-INLINE-NEXT: call void @__asan_set_shadow_04(i64 [[TMP35]], i64 1)
; CHECK-INLINE-NEXT: [[TMP36:%.*]] = add i64 [[TMP29]], 1065
; CHECK-INLINE-NEXT: call void @__asan_set_shadow_f2(i64 [[TMP36]], i64 1)
; CHECK-INLINE-NEXT: [[TMP37:%.*]] = add i64 [[TMP29]], 1066
; CHECK-INLINE-NEXT: call void @__asan_set_shadow_f8(i64 [[TMP37]], i64 1)
; CHECK-INLINE-NEXT: [[TMP38:%.*]] = add i64 [[TMP29]], 1067
; CHECK-INLINE-NEXT: call void @__asan_set_shadow_f3(i64 [[TMP38]], i64 1)
; CHECK-INLINE-NEXT: [[TMP39:%.*]] = add i64 [[TMP29]], 1066
; CHECK-INLINE-NEXT: call void @__asan_set_shadow_04(i64 [[TMP39]], i64 1)
; CHECK-INLINE-NEXT: [[TMP40:%.*]] = lshr i64 [[TMP21]], 3
; CHECK-INLINE-NEXT: [[TMP41:%.*]] = add i64 [[TMP40]], [[TMP1]]
; CHECK-INLINE-NEXT: [[TMP42:%.*]] = inttoptr i64 [[TMP41]] to ptr
; CHECK-INLINE-NEXT: [[TMP43:%.*]] = load i8, ptr [[TMP42]], align 1
; CHECK-INLINE-NEXT: [[TMP44:%.*]] = icmp ne i8 [[TMP43]], 0
; CHECK-INLINE-NEXT: br i1 [[TMP44]], label [[TMP45:%.*]], label [[TMP50:%.*]], !prof [[PROF1:![0-9]+]]
; CHECK-INLINE: 45:
; CHECK-INLINE-NEXT: [[TMP46:%.*]] = and i64 [[TMP21]], 7
; CHECK-INLINE-NEXT: [[TMP47:%.*]] = trunc i64 [[TMP46]] to i8
; CHECK-INLINE-NEXT: [[TMP48:%.*]] = icmp sge i8 [[TMP47]], [[TMP43]]
; CHECK-INLINE-NEXT: br i1 [[TMP48]], label [[TMP49:%.*]], label [[TMP50]]
; CHECK-INLINE: 49:
; CHECK-INLINE-NEXT: call void @__asan_report_store1(i64 [[TMP21]]) #[[ATTR7:[0-9]+]]
; CHECK-INLINE-NEXT: unreachable
; CHECK-INLINE: 50:
; CHECK-INLINE-NEXT: store volatile i8 0, ptr [[TMP22]], align 1
; CHECK-INLINE-NEXT: [[TMP51:%.*]] = add i64 [[TMP29]], 1066
; CHECK-INLINE-NEXT: call void @__asan_set_shadow_f8(i64 [[TMP51]], i64 1)
; CHECK-INLINE-NEXT: [[TMP52:%.*]] = alloca i8, i64 96, align 32
; CHECK-INLINE-NEXT: [[TMP53:%.*]] = ptrtoint ptr [[TMP52]] to i64
; CHECK-INLINE-NEXT: [[TMP54:%.*]] = add i64 [[TMP53]], 32
; CHECK-INLINE-NEXT: call void @__asan_alloca_poison(i64 [[TMP54]], i64 4)
; CHECK-INLINE-NEXT: [[TMP55:%.*]] = ptrtoint ptr [[TMP52]] to i64
; CHECK-INLINE-NEXT: store i64 [[TMP55]], ptr [[TMP0]], align 8
; CHECK-INLINE-NEXT: [[TMP56:%.*]] = inttoptr i64 [[TMP54]] to ptr
; CHECK-INLINE-NEXT: [[TMP57:%.*]] = alloca i8, i64 96, align 32
; CHECK-INLINE-NEXT: [[TMP58:%.*]] = ptrtoint ptr [[TMP57]] to i64
; CHECK-INLINE-NEXT: [[TMP59:%.*]] = add i64 [[TMP58]], 32
; CHECK-INLINE-NEXT: call void @__asan_alloca_poison(i64 [[TMP59]], i64 8)
; CHECK-INLINE-NEXT: [[TMP60:%.*]] = ptrtoint ptr [[TMP57]] to i64
; CHECK-INLINE-NEXT: store i64 [[TMP60]], ptr [[TMP0]], align 8
; CHECK-INLINE-NEXT: [[TMP61:%.*]] = inttoptr i64 [[TMP59]] to ptr
; CHECK-INLINE-NEXT: [[TMP62:%.*]] = lshr i64 [[TMP59]], 3
; CHECK-INLINE-NEXT: [[TMP63:%.*]] = add i64 [[TMP62]], [[TMP1]]
; CHECK-INLINE-NEXT: [[TMP64:%.*]] = inttoptr i64 [[TMP63]] to ptr
; CHECK-INLINE-NEXT: [[TMP65:%.*]] = load i8, ptr [[TMP64]], align 1
; CHECK-INLINE-NEXT: [[TMP66:%.*]] = icmp ne i8 [[TMP65]], 0
; CHECK-INLINE-NEXT: br i1 [[TMP66]], label [[TMP67:%.*]], label [[TMP68:%.*]]
; CHECK-INLINE: 67:
; CHECK-INLINE-NEXT: call void @__asan_report_store8(i64 [[TMP59]]) #[[ATTR7]]
; CHECK-INLINE-NEXT: unreachable
; CHECK-INLINE: 68:
; CHECK-INLINE-NEXT: store volatile i64 0, ptr [[TMP61]], align 8
; CHECK-INLINE-NEXT: [[TMPCOPYI64:%.*]] = load i64, ptr [[TMP61]], align 8
; CHECK-INLINE-NEXT: [[TMP69:%.*]] = and i64 [[TMPCOPYI64]], 31
; CHECK-INLINE-NEXT: [[TMP70:%.*]] = sub i64 32, [[TMP69]]
; CHECK-INLINE-NEXT: [[TMP71:%.*]] = icmp ne i64 [[TMP70]], 32
; CHECK-INLINE-NEXT: [[TMP72:%.*]] = select i1 [[TMP71]], i64 [[TMP70]], i64 0
; CHECK-INLINE-NEXT: [[TMP73:%.*]] = add i64 64, [[TMP72]]
; CHECK-INLINE-NEXT: [[TMP74:%.*]] = add i64 [[TMPCOPYI64]], [[TMP73]]
; CHECK-INLINE-NEXT: [[TMP75:%.*]] = alloca i8, i64 [[TMP74]], align 32
; CHECK-INLINE-NEXT: [[TMP76:%.*]] = ptrtoint ptr [[TMP75]] to i64
; CHECK-INLINE-NEXT: [[TMP77:%.*]] = add i64 [[TMP76]], 32
; CHECK-INLINE-NEXT: call void @__asan_alloca_poison(i64 [[TMP77]], i64 [[TMPCOPYI64]])
; CHECK-INLINE-NEXT: [[TMP78:%.*]] = ptrtoint ptr [[TMP75]] to i64
; CHECK-INLINE-NEXT: store i64 [[TMP78]], ptr [[TMP0]], align 8
; CHECK-INLINE-NEXT: [[TMP79:%.*]] = inttoptr i64 [[TMP77]] to ptr
; CHECK-INLINE-NEXT: [[TMP80:%.*]] = lshr i64 [[TMP77]], 3
; CHECK-INLINE-NEXT: [[TMP81:%.*]] = add i64 [[TMP80]], [[TMP1]]
; CHECK-INLINE-NEXT: [[TMP82:%.*]] = inttoptr i64 [[TMP81]] to ptr
; CHECK-INLINE-NEXT: [[TMP83:%.*]] = load i8, ptr [[TMP82]], align 1
; CHECK-INLINE-NEXT: [[TMP84:%.*]] = icmp ne i8 [[TMP83]], 0
; CHECK-INLINE-NEXT: br i1 [[TMP84]], label [[TMP85:%.*]], label [[TMP90:%.*]], !prof [[PROF1]]
; CHECK-INLINE: 85:
; CHECK-INLINE-NEXT: [[TMP86:%.*]] = and i64 [[TMP77]], 7
; CHECK-INLINE-NEXT: [[TMP87:%.*]] = trunc i64 [[TMP86]] to i8
; CHECK-INLINE-NEXT: [[TMP88:%.*]] = icmp sge i8 [[TMP87]], [[TMP83]]
; CHECK-INLINE-NEXT: br i1 [[TMP88]], label [[TMP89:%.*]], label [[TMP90]]
; CHECK-INLINE: 89:
; CHECK-INLINE-NEXT: call void @__asan_report_store1(i64 [[TMP77]]) #[[ATTR7]]
; CHECK-INLINE-NEXT: unreachable
; CHECK-INLINE: 90:
; CHECK-INLINE-NEXT: store volatile i8 0, ptr [[TMP79]], align 1
; CHECK-INLINE-NEXT: invoke void @MayThrowFunc()
; CHECK-INLINE-NEXT: to label [[INVOKE_CONT:%.*]] unwind label [[EHCLEANUP:%.*]]
; CHECK-INLINE: invoke.cont:
; CHECK-INLINE-NEXT: call void @DeInit(ptr [[TMP14]])
; CHECK-INLINE-NEXT: [[TMP91:%.*]] = ptrtoint ptr [[TMP0]] to i64
; CHECK-INLINE-NEXT: [[TMP92:%.*]] = load i64, ptr [[TMP0]], align 8
; CHECK-INLINE-NEXT: call void @__asan_allocas_unpoison(i64 [[TMP92]], i64 [[TMP91]])
; CHECK-INLINE-NEXT: store i64 1172321806, ptr [[TMP23]], align 8
; CHECK-INLINE-NEXT: [[TMP93:%.*]] = icmp ne i64 [[TMP7]], 0
; CHECK-INLINE-NEXT: br i1 [[TMP93]], label [[TMP94:%.*]], label [[TMP95:%.*]]
; CHECK-INLINE: 94:
; CHECK-INLINE-NEXT: call void @__asan_stack_free_8(i64 [[TMP7]], i64 8544)
; CHECK-INLINE-NEXT: br label [[TMP97:%.*]]
; CHECK-INLINE: 95:
; CHECK-INLINE-NEXT: call void @__asan_set_shadow_00(i64 [[TMP29]], i64 4)
; CHECK-INLINE-NEXT: [[TMP96:%.*]] = add i64 [[TMP29]], 1028
; CHECK-INLINE-NEXT: call void @__asan_set_shadow_00(i64 [[TMP96]], i64 40)
; CHECK-INLINE-NEXT: br label [[TMP97]]
; CHECK-INLINE: 97:
; CHECK-INLINE-NEXT: ret void
; CHECK-INLINE: ehcleanup:
; CHECK-INLINE-NEXT: [[TMP98:%.*]] = cleanuppad within none []
; CHECK-INLINE-NEXT: call void @__asan_unpoison_stack_memory(i64 [[TMP54]], i64 4) [ "funclet"(token [[TMP98]]) ]
; CHECK-INLINE-NEXT: [[TMP99:%.*]] = lshr i64 [[TMP54]], 3
; CHECK-INLINE-NEXT: [[TMP100:%.*]] = add i64 [[TMP99]], [[TMP1]]
; CHECK-INLINE-NEXT: [[TMP101:%.*]] = inttoptr i64 [[TMP100]] to ptr
; CHECK-INLINE-NEXT: [[TMP102:%.*]] = load i8, ptr [[TMP101]], align 1
; CHECK-INLINE-NEXT: [[TMP103:%.*]] = icmp ne i8 [[TMP102]], 0
; CHECK-INLINE-NEXT: br i1 [[TMP103]], label [[TMP104:%.*]], label [[TMP109:%.*]], !prof [[PROF1]]
; CHECK-INLINE: 104:
; CHECK-INLINE-NEXT: [[TMP105:%.*]] = and i64 [[TMP54]], 7
; CHECK-INLINE-NEXT: [[TMP106:%.*]] = trunc i64 [[TMP105]] to i8
; CHECK-INLINE-NEXT: [[TMP107:%.*]] = icmp sge i8 [[TMP106]], [[TMP102]]
; CHECK-INLINE-NEXT: br i1 [[TMP107]], label [[TMP108:%.*]], label [[TMP109]]
; CHECK-INLINE: 108:
; CHECK-INLINE-NEXT: call void @__asan_report_store1(i64 [[TMP54]]) #[[ATTR7]] [ "funclet"(token [[TMP98]]) ]
; CHECK-INLINE-NEXT: unreachable
; CHECK-INLINE: 109:
; CHECK-INLINE-NEXT: store volatile i8 0, ptr [[TMP56]], align 1
; CHECK-INLINE-NEXT: call void @__asan_poison_stack_memory(i64 [[TMP54]], i64 4) [ "funclet"(token [[TMP98]]) ]
; CHECK-INLINE-NEXT: call void @DeInit(ptr [[TMP14]]) [ "funclet"(token [[TMP98]]) ]
; CHECK-INLINE-NEXT: [[TMP110:%.*]] = call ptr @__asan_memset(ptr [[TMP16]], i32 0, i64 4) [ "funclet"(token [[TMP98]]) ]
; CHECK-INLINE-NEXT: [[TMP111:%.*]] = call ptr @__asan_memcpy(ptr [[TMP18]], ptr [[TMP16]], i64 4) [ "funclet"(token [[TMP98]]) ]
; CHECK-INLINE-NEXT: [[TMP112:%.*]] = call ptr @__asan_memmove(ptr [[TMP20]], ptr [[TMP16]], i64 4) [ "funclet"(token [[TMP98]]) ]
; CHECK-INLINE-NEXT: call void @__sanitizer_ptr_cmp(i64 [[TMP15]], i64 [[TMP17]]) [ "funclet"(token [[TMP98]]) ]
; CHECK-INLINE-NEXT: call void @__sanitizer_ptr_sub(i64 [[TMP15]], i64 [[TMP17]]) [ "funclet"(token [[TMP98]]) ]
; CHECK-INLINE-NEXT: [[TMP113:%.*]] = ptrtoint ptr [[PTRPARAM]] to i64
; CHECK-INLINE-NEXT: [[TMP114:%.*]] = add i64 [[TMP113]], 7
; CHECK-INLINE-NEXT: [[TMP115:%.*]] = inttoptr i64 [[TMP114]] to ptr
; CHECK-INLINE-NEXT: [[TMP116:%.*]] = ptrtoint ptr [[PTRPARAM]] to i64
; CHECK-INLINE-NEXT: [[TMP117:%.*]] = lshr i64 [[TMP116]], 3
; CHECK-INLINE-NEXT: [[TMP118:%.*]] = add i64 [[TMP117]], [[TMP1]]
; CHECK-INLINE-NEXT: [[TMP119:%.*]] = inttoptr i64 [[TMP118]] to ptr
; CHECK-INLINE-NEXT: [[TMP120:%.*]] = load i8, ptr [[TMP119]], align 1
; CHECK-INLINE-NEXT: [[TMP121:%.*]] = icmp ne i8 [[TMP120]], 0
; CHECK-INLINE-NEXT: br i1 [[TMP121]], label [[TMP122:%.*]], label [[TMP127:%.*]], !prof [[PROF1]]
; CHECK-INLINE: 122:
; CHECK-INLINE-NEXT: [[TMP123:%.*]] = and i64 [[TMP116]], 7
; CHECK-INLINE-NEXT: [[TMP124:%.*]] = trunc i64 [[TMP123]] to i8
; CHECK-INLINE-NEXT: [[TMP125:%.*]] = icmp sge i8 [[TMP124]], [[TMP120]]
; CHECK-INLINE-NEXT: br i1 [[TMP125]], label [[TMP126:%.*]], label [[TMP127]]
; CHECK-INLINE: 126:
; CHECK-INLINE-NEXT: call void @__asan_report_store_n(i64 [[TMP116]], i64 8) #[[ATTR7]] [ "funclet"(token [[TMP98]]) ]
; CHECK-INLINE-NEXT: unreachable
; CHECK-INLINE: 127:
; CHECK-INLINE-NEXT: [[TMP128:%.*]] = lshr i64 [[TMP114]], 3
; CHECK-INLINE-NEXT: [[TMP129:%.*]] = add i64 [[TMP128]], [[TMP1]]
; CHECK-INLINE-NEXT: [[TMP130:%.*]] = inttoptr i64 [[TMP129]] to ptr
; CHECK-INLINE-NEXT: [[TMP131:%.*]] = load i8, ptr [[TMP130]], align 1
; CHECK-INLINE-NEXT: [[TMP132:%.*]] = icmp ne i8 [[TMP131]], 0
; CHECK-INLINE-NEXT: br i1 [[TMP132]], label [[TMP133:%.*]], label [[EHEXIT:%.*]], !prof [[PROF1]]
; CHECK-INLINE: 133:
; CHECK-INLINE-NEXT: [[TMP134:%.*]] = and i64 [[TMP114]], 7
; CHECK-INLINE-NEXT: [[TMP135:%.*]] = trunc i64 [[TMP134]] to i8
; CHECK-INLINE-NEXT: [[TMP136:%.*]] = icmp sge i8 [[TMP135]], [[TMP131]]
; CHECK-INLINE-NEXT: br i1 [[TMP136]], label [[TMP137:%.*]], label [[EHEXIT]]
; CHECK-INLINE: 137:
; CHECK-INLINE-NEXT: call void @__asan_report_store_n(i64 [[TMP114]], i64 8) #[[ATTR7]] [ "funclet"(token [[TMP98]]) ]
; CHECK-INLINE-NEXT: unreachable
; CHECK-INLINE: ehexit:
; CHECK-INLINE-NEXT: store i64 0, ptr [[PTRPARAM]], align 1
; CHECK-INLINE-NEXT: [[TMP138:%.*]] = call i64 @llvm.get.dynamic.area.offset.i64()
; CHECK-INLINE-NEXT: [[TMP139:%.*]] = ptrtoint ptr [[TMP0]] to i64
; CHECK-INLINE-NEXT: [[TMP140:%.*]] = add i64 [[TMP139]], [[TMP138]]
; CHECK-INLINE-NEXT: [[TMP141:%.*]] = load i64, ptr [[TMP0]], align 8
; CHECK-INLINE-NEXT: call void @__asan_allocas_unpoison(i64 [[TMP141]], i64 [[TMP140]]) [ "funclet"(token [[TMP98]]) ]
; CHECK-INLINE-NEXT: store i64 1172321806, ptr [[TMP23]], align 8
; CHECK-INLINE-NEXT: [[TMP142:%.*]] = icmp ne i64 [[TMP7]], 0
; CHECK-INLINE-NEXT: br i1 [[TMP142]], label [[TMP143:%.*]], label [[TMP144:%.*]]
; CHECK-INLINE: 143:
; CHECK-INLINE-NEXT: call void @__asan_stack_free_8(i64 [[TMP7]], i64 8544) [ "funclet"(token [[TMP98]]) ]
; CHECK-INLINE-NEXT: br label [[TMP146:%.*]]
; CHECK-INLINE: 144:
; CHECK-INLINE-NEXT: call void @__asan_set_shadow_00(i64 [[TMP29]], i64 4) [ "funclet"(token [[TMP98]]) ]
; CHECK-INLINE-NEXT: [[TMP145:%.*]] = add i64 [[TMP29]], 1028
; CHECK-INLINE-NEXT: call void @__asan_set_shadow_00(i64 [[TMP145]], i64 40) [ "funclet"(token [[TMP98]]) ]
; CHECK-INLINE-NEXT: br label [[TMP146]]
; CHECK-INLINE: 146:
; CHECK-INLINE-NEXT: cleanupret from [[TMP98]] unwind to caller
;
; CHECK-OUTLINE-LABEL: define void @FuncletPersonality(
; CHECK-OUTLINE-SAME: ptr [[PTRPARAM:%.*]]) #[[ATTR3:[0-9]+]] personality ptr @__CxxFrameHandler3 {
; CHECK-OUTLINE-NEXT: entry:
; CHECK-OUTLINE-NEXT: [[TMP0:%.*]] = alloca i64, align 32
; CHECK-OUTLINE-NEXT: store i64 0, ptr [[TMP0]], align 8
; CHECK-OUTLINE-NEXT: [[TMP1:%.*]] = load i64, ptr @__asan_shadow_memory_dynamic_address, align 8
; CHECK-OUTLINE-NEXT: [[ASAN_LOCAL_STACK_BASE:%.*]] = alloca i64, align 8
; CHECK-OUTLINE-NEXT: [[TMP2:%.*]] = load i32, ptr @__asan_option_detect_stack_use_after_return, align 4
; CHECK-OUTLINE-NEXT: [[TMP3:%.*]] = icmp ne i32 [[TMP2]], 0
; CHECK-OUTLINE-NEXT: br i1 [[TMP3]], label [[TMP4:%.*]], label [[TMP6:%.*]]
; CHECK-OUTLINE: 4:
; CHECK-OUTLINE-NEXT: [[TMP5:%.*]] = call i64 @__asan_stack_malloc_8(i64 8608)
; CHECK-OUTLINE-NEXT: br label [[TMP6]]
; CHECK-OUTLINE: 6:
; CHECK-OUTLINE-NEXT: [[TMP7:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[TMP5]], [[TMP4]] ]
; CHECK-OUTLINE-NEXT: [[TMP8:%.*]] = icmp eq i64 [[TMP7]], 0
; CHECK-OUTLINE-NEXT: br i1 [[TMP8]], label [[TMP9:%.*]], label [[TMP11:%.*]]
; CHECK-OUTLINE: 9:
; CHECK-OUTLINE-NEXT: [[MYALLOCA:%.*]] = alloca i8, i64 8608, align 32
; CHECK-OUTLINE-NEXT: [[TMP10:%.*]] = ptrtoint ptr [[MYALLOCA]] to i64
; CHECK-OUTLINE-NEXT: br label [[TMP11]]
; CHECK-OUTLINE: 11:
; CHECK-OUTLINE-NEXT: [[TMP12:%.*]] = phi i64 [ [[TMP7]], [[TMP6]] ], [ [[TMP10]], [[TMP9]] ]
; CHECK-OUTLINE-NEXT: store i64 [[TMP12]], ptr [[ASAN_LOCAL_STACK_BASE]], align 8
; CHECK-OUTLINE-NEXT: [[TMP13:%.*]] = add i64 [[TMP12]], 32
; CHECK-OUTLINE-NEXT: [[TMP14:%.*]] = inttoptr i64 [[TMP13]] to ptr
; CHECK-OUTLINE-NEXT: [[TMP15:%.*]] = add i64 [[TMP12]], 8480
; CHECK-OUTLINE-NEXT: [[TMP16:%.*]] = inttoptr i64 [[TMP15]] to ptr
; CHECK-OUTLINE-NEXT: [[TMP17:%.*]] = add i64 [[TMP12]], 8496
; CHECK-OUTLINE-NEXT: [[TMP18:%.*]] = inttoptr i64 [[TMP17]] to ptr
; CHECK-OUTLINE-NEXT: [[TMP19:%.*]] = add i64 [[TMP12]], 8512
; CHECK-OUTLINE-NEXT: [[TMP20:%.*]] = inttoptr i64 [[TMP19]] to ptr
; CHECK-OUTLINE-NEXT: [[TMP21:%.*]] = add i64 [[TMP12]], 8528
; CHECK-OUTLINE-NEXT: [[TMP22:%.*]] = inttoptr i64 [[TMP21]] to ptr
; CHECK-OUTLINE-NEXT: [[TMP23:%.*]] = add i64 [[TMP12]], 8544
; CHECK-OUTLINE-NEXT: [[TMP24:%.*]] = inttoptr i64 [[TMP23]] to ptr
; CHECK-OUTLINE-NEXT: [[TMP25:%.*]] = add i64 [[TMP12]], 8560
; CHECK-OUTLINE-NEXT: [[TMP26:%.*]] = inttoptr i64 [[TMP25]] to ptr
; CHECK-OUTLINE-NEXT: [[TMP27:%.*]] = inttoptr i64 [[TMP12]] to ptr
; CHECK-OUTLINE-NEXT: store i64 1102416563, ptr [[TMP27]], align 8
; CHECK-OUTLINE-NEXT: [[TMP28:%.*]] = add i64 [[TMP12]], 8
; CHECK-OUTLINE-NEXT: [[TMP29:%.*]] = inttoptr i64 [[TMP28]] to ptr
; CHECK-OUTLINE-NEXT: store i64 ptrtoint (ptr @___asan_gen_stack to i64), ptr [[TMP29]], align 8
; CHECK-OUTLINE-NEXT: [[TMP30:%.*]] = add i64 [[TMP12]], 16
; CHECK-OUTLINE-NEXT: [[TMP31:%.*]] = inttoptr i64 [[TMP30]] to ptr
; CHECK-OUTLINE-NEXT: store i64 ptrtoint (ptr @FuncletPersonality to i64), ptr [[TMP31]], align 8
; CHECK-OUTLINE-NEXT: [[TMP32:%.*]] = lshr i64 [[TMP12]], 3
; CHECK-OUTLINE-NEXT: [[TMP33:%.*]] = add i64 [[TMP32]], [[TMP1]]
; CHECK-OUTLINE-NEXT: call void @__asan_set_shadow_f1(i64 [[TMP33]], i64 4)
; CHECK-OUTLINE-NEXT: [[TMP34:%.*]] = add i64 [[TMP33]], 1028
; CHECK-OUTLINE-NEXT: call void @__asan_set_shadow_f2(i64 [[TMP34]], i64 32)
; CHECK-OUTLINE-NEXT: [[TMP35:%.*]] = add i64 [[TMP33]], 1060
; CHECK-OUTLINE-NEXT: call void @__asan_set_shadow_04(i64 [[TMP35]], i64 1)
; CHECK-OUTLINE-NEXT: [[TMP36:%.*]] = add i64 [[TMP33]], 1061
; CHECK-OUTLINE-NEXT: call void @__asan_set_shadow_f2(i64 [[TMP36]], i64 1)
; CHECK-OUTLINE-NEXT: [[TMP37:%.*]] = add i64 [[TMP33]], 1062
; CHECK-OUTLINE-NEXT: call void @__asan_set_shadow_04(i64 [[TMP37]], i64 1)
; CHECK-OUTLINE-NEXT: [[TMP38:%.*]] = add i64 [[TMP33]], 1063
; CHECK-OUTLINE-NEXT: call void @__asan_set_shadow_f2(i64 [[TMP38]], i64 1)
; CHECK-OUTLINE-NEXT: [[TMP39:%.*]] = add i64 [[TMP33]], 1064
; CHECK-OUTLINE-NEXT: call void @__asan_set_shadow_04(i64 [[TMP39]], i64 1)
; CHECK-OUTLINE-NEXT: [[TMP40:%.*]] = add i64 [[TMP33]], 1065
; CHECK-OUTLINE-NEXT: call void @__asan_set_shadow_f2(i64 [[TMP40]], i64 1)
; CHECK-OUTLINE-NEXT: [[TMP41:%.*]] = add i64 [[TMP33]], 1066
; CHECK-OUTLINE-NEXT: call void @__asan_set_shadow_f8(i64 [[TMP41]], i64 1)
; CHECK-OUTLINE-NEXT: [[TMP42:%.*]] = add i64 [[TMP33]], 1067
; CHECK-OUTLINE-NEXT: call void @__asan_set_shadow_f2(i64 [[TMP42]], i64 1)
; CHECK-OUTLINE-NEXT: [[TMP43:%.*]] = add i64 [[TMP33]], 1068
; CHECK-OUTLINE-NEXT: call void @__asan_set_shadow_f8(i64 [[TMP43]], i64 1)
; CHECK-OUTLINE-NEXT: [[TMP44:%.*]] = add i64 [[TMP33]], 1069
; CHECK-OUTLINE-NEXT: call void @__asan_set_shadow_f2(i64 [[TMP44]], i64 1)
; CHECK-OUTLINE-NEXT: [[TMP45:%.*]] = add i64 [[TMP33]], 1071
; CHECK-OUTLINE-NEXT: call void @__asan_set_shadow_f3(i64 [[TMP45]], i64 5)
; CHECK-OUTLINE-NEXT: [[TMP46:%.*]] = add i64 [[TMP33]], 1066
; CHECK-OUTLINE-NEXT: call void @__asan_set_shadow_04(i64 [[TMP46]], i64 1)
; CHECK-OUTLINE-NEXT: call void @__asan_store1(i64 [[TMP21]])
; CHECK-OUTLINE-NEXT: store volatile i8 0, ptr [[TMP22]], align 1
; CHECK-OUTLINE-NEXT: [[TMP47:%.*]] = add i64 [[TMP33]], 1066
; CHECK-OUTLINE-NEXT: call void @__asan_set_shadow_f8(i64 [[TMP47]], i64 1)
; CHECK-OUTLINE-NEXT: call void @__asan_store8(i64 [[TMP25]])
; CHECK-OUTLINE-NEXT: store volatile i64 0, ptr [[TMP26]], align 8
; CHECK-OUTLINE-NEXT: [[TMPCOPYI64:%.*]] = load i64, ptr [[TMP26]], align 8
; CHECK-OUTLINE-NEXT: [[TMP48:%.*]] = and i64 [[TMPCOPYI64]], 31
; CHECK-OUTLINE-NEXT: [[TMP49:%.*]] = sub i64 32, [[TMP48]]
; CHECK-OUTLINE-NEXT: [[TMP50:%.*]] = icmp ne i64 [[TMP49]], 32
; CHECK-OUTLINE-NEXT: [[TMP51:%.*]] = select i1 [[TMP50]], i64 [[TMP49]], i64 0
; CHECK-OUTLINE-NEXT: [[TMP52:%.*]] = add i64 64, [[TMP51]]
; CHECK-OUTLINE-NEXT: [[TMP53:%.*]] = add i64 [[TMPCOPYI64]], [[TMP52]]
; CHECK-OUTLINE-NEXT: [[TMP54:%.*]] = alloca i8, i64 [[TMP53]], align 32
; CHECK-OUTLINE-NEXT: [[TMP55:%.*]] = ptrtoint ptr [[TMP54]] to i64
; CHECK-OUTLINE-NEXT: [[TMP56:%.*]] = add i64 [[TMP55]], 32
; CHECK-OUTLINE-NEXT: call void @__asan_alloca_poison(i64 [[TMP56]], i64 [[TMPCOPYI64]])
; CHECK-OUTLINE-NEXT: [[TMP57:%.*]] = ptrtoint ptr [[TMP54]] to i64
; CHECK-OUTLINE-NEXT: store i64 [[TMP57]], ptr [[TMP0]], align 8
; CHECK-OUTLINE-NEXT: [[TMP58:%.*]] = inttoptr i64 [[TMP56]] to ptr
; CHECK-OUTLINE-NEXT: call void @__asan_store1(i64 [[TMP56]])
; CHECK-OUTLINE-NEXT: store volatile i8 0, ptr [[TMP58]], align 1
; CHECK-OUTLINE-NEXT: invoke void @MayThrowFunc()
; CHECK-OUTLINE-NEXT: to label [[INVOKE_CONT:%.*]] unwind label [[EHCLEANUP:%.*]]
; CHECK-OUTLINE: invoke.cont:
; CHECK-OUTLINE-NEXT: call void @DeInit(ptr [[TMP14]])
; CHECK-OUTLINE-NEXT: [[TMP59:%.*]] = ptrtoint ptr [[TMP0]] to i64
; CHECK-OUTLINE-NEXT: [[TMP60:%.*]] = load i64, ptr [[TMP0]], align 8
; CHECK-OUTLINE-NEXT: call void @__asan_allocas_unpoison(i64 [[TMP60]], i64 [[TMP59]])
; CHECK-OUTLINE-NEXT: store i64 1172321806, ptr [[TMP27]], align 8
; CHECK-OUTLINE-NEXT: [[TMP61:%.*]] = icmp ne i64 [[TMP7]], 0
; CHECK-OUTLINE-NEXT: br i1 [[TMP61]], label [[TMP62:%.*]], label [[TMP63:%.*]]
; CHECK-OUTLINE: 62:
; CHECK-OUTLINE-NEXT: call void @__asan_stack_free_8(i64 [[TMP7]], i64 8608)
; CHECK-OUTLINE-NEXT: br label [[TMP66:%.*]]
; CHECK-OUTLINE: 63:
; CHECK-OUTLINE-NEXT: call void @__asan_set_shadow_00(i64 [[TMP33]], i64 4)
; CHECK-OUTLINE-NEXT: [[TMP64:%.*]] = add i64 [[TMP33]], 1028
; CHECK-OUTLINE-NEXT: call void @__asan_set_shadow_00(i64 [[TMP64]], i64 42)
; CHECK-OUTLINE-NEXT: [[TMP65:%.*]] = add i64 [[TMP33]], 1071
; CHECK-OUTLINE-NEXT: call void @__asan_set_shadow_00(i64 [[TMP65]], i64 5)
; CHECK-OUTLINE-NEXT: br label [[TMP66]]
; CHECK-OUTLINE: 66:
; CHECK-OUTLINE-NEXT: ret void
; CHECK-OUTLINE: ehcleanup:
; CHECK-OUTLINE-NEXT: [[TMP67:%.*]] = cleanuppad within none []
; CHECK-OUTLINE-NEXT: [[TMP68:%.*]] = add i64 [[TMP33]], 1068
; CHECK-OUTLINE-NEXT: call void @__asan_set_shadow_04(i64 [[TMP68]], i64 1) [ "funclet"(token [[TMP67]]) ]
; CHECK-OUTLINE-NEXT: call void @__asan_store1(i64 [[TMP23]]) [ "funclet"(token [[TMP67]]) ]
; CHECK-OUTLINE-NEXT: store volatile i8 0, ptr [[TMP24]], align 1
; CHECK-OUTLINE-NEXT: [[TMP69:%.*]] = add i64 [[TMP33]], 1068
; CHECK-OUTLINE-NEXT: call void @__asan_set_shadow_f8(i64 [[TMP69]], i64 1) [ "funclet"(token [[TMP67]]) ]
; CHECK-OUTLINE-NEXT: call void @DeInit(ptr [[TMP14]]) [ "funclet"(token [[TMP67]]) ]
; CHECK-OUTLINE-NEXT: [[TMP70:%.*]] = call ptr @__asan_memset(ptr [[TMP16]], i32 0, i64 4) [ "funclet"(token [[TMP67]]) ]
; CHECK-OUTLINE-NEXT: [[TMP71:%.*]] = call ptr @__asan_memcpy(ptr [[TMP18]], ptr [[TMP16]], i64 4) [ "funclet"(token [[TMP67]]) ]
; CHECK-OUTLINE-NEXT: [[TMP72:%.*]] = call ptr @__asan_memmove(ptr [[TMP20]], ptr [[TMP16]], i64 4) [ "funclet"(token [[TMP67]]) ]
; CHECK-OUTLINE-NEXT: call void @__sanitizer_ptr_cmp(i64 [[TMP15]], i64 [[TMP17]]) [ "funclet"(token [[TMP67]]) ]
; CHECK-OUTLINE-NEXT: call void @__sanitizer_ptr_sub(i64 [[TMP15]], i64 [[TMP17]]) [ "funclet"(token [[TMP67]]) ]
; CHECK-OUTLINE-NEXT: [[TMP73:%.*]] = ptrtoint ptr [[PTRPARAM]] to i64
; CHECK-OUTLINE-NEXT: call void @__asan_storeN(i64 [[TMP73]], i64 8) [ "funclet"(token [[TMP67]]) ]
; CHECK-OUTLINE-NEXT: store i64 0, ptr [[PTRPARAM]], align 1
; CHECK-OUTLINE-NEXT: [[TMP74:%.*]] = call i64 @llvm.get.dynamic.area.offset.i64()
; CHECK-OUTLINE-NEXT: [[TMP75:%.*]] = ptrtoint ptr [[TMP0]] to i64
; CHECK-OUTLINE-NEXT: [[TMP76:%.*]] = add i64 [[TMP75]], [[TMP74]]
; CHECK-OUTLINE-NEXT: [[TMP77:%.*]] = load i64, ptr [[TMP0]], align 8
; CHECK-OUTLINE-NEXT: call void @__asan_allocas_unpoison(i64 [[TMP77]], i64 [[TMP76]]) [ "funclet"(token [[TMP67]]) ]
; CHECK-OUTLINE-NEXT: store i64 1172321806, ptr [[TMP27]], align 8
; CHECK-OUTLINE-NEXT: [[TMP78:%.*]] = icmp ne i64 [[TMP7]], 0
; CHECK-OUTLINE-NEXT: br i1 [[TMP78]], label [[TMP79:%.*]], label [[TMP80:%.*]]
; CHECK-OUTLINE: 79:
; CHECK-OUTLINE-NEXT: call void @__asan_stack_free_8(i64 [[TMP7]], i64 8608) [ "funclet"(token [[TMP67]]) ]
; CHECK-OUTLINE-NEXT: br label [[TMP83:%.*]]
; CHECK-OUTLINE: 80:
; CHECK-OUTLINE-NEXT: call void @__asan_set_shadow_00(i64 [[TMP33]], i64 4) [ "funclet"(token [[TMP67]]) ]
; CHECK-OUTLINE-NEXT: [[TMP81:%.*]] = add i64 [[TMP33]], 1028
; CHECK-OUTLINE-NEXT: call void @__asan_set_shadow_00(i64 [[TMP81]], i64 42) [ "funclet"(token [[TMP67]]) ]
; CHECK-OUTLINE-NEXT: [[TMP82:%.*]] = add i64 [[TMP33]], 1071
; CHECK-OUTLINE-NEXT: call void @__asan_set_shadow_00(i64 [[TMP82]], i64 5) [ "funclet"(token [[TMP67]]) ]
; CHECK-OUTLINE-NEXT: br label [[TMP83]]
; CHECK-OUTLINE: 83:
; CHECK-OUTLINE-NEXT: cleanupret from [[TMP67]] unwind to caller
;
entry:
; Large enough local alloca to have asan generate a __asan_stack_free_#() call
%largeObj = alloca [2048 x i32], align 16
%tmpInt1 = alloca i32, align 4
%tmpInt2 = alloca i32, align 4
%tmpInt3 = alloca i32, align 4
; Creating %lifetimeInt and %lifetimeArr, and managing their lifetimes
; to make asan generate stack poisoning calls
%lifetimeInt = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr %lifetimeInt)
store volatile i8 0, ptr %lifetimeInt
call void @llvm.lifetime.end.p0(i64 4, ptr %lifetimeInt)
%lifetimeArr = alloca i32, align 4
; Dynamic alloca to generate a @__asan_allocas_unpoison call in ehcleanup
%tmpVolatilei64 = alloca i64, align 8
store volatile i64 0, ptr %tmpVolatilei64, align 8
%tmpCopyi64 = load i64, ptr %tmpVolatilei64, align 8
%tmpVolatilei8 = alloca i8, i64 %tmpCopyi64, align 32
store volatile i8 0, ptr %tmpVolatilei8
invoke void @MayThrowFunc()
to label %invoke.cont unwind label %ehcleanup
invoke.cont: ; preds = %entry
call void @DeInit(ptr %largeObj)
ret void
ehcleanup: ; preds = %entry
%0 = cleanuppad within none []
; Make asan add a call to __asan_unpoison_stack_memory
call void @llvm.lifetime.start.p0(i64 4, ptr %lifetimeArr)
; Make asan add a call to __asan_report_store1
store volatile i8 0, ptr %lifetimeArr
; Make asan add a call to __asan_poison_stack_memory
call void @llvm.lifetime.end.p0(i64 4, ptr %lifetimeArr)
call void @DeInit(ptr %largeObj) [ "funclet"(token %0) ]
call void @llvm.memset.p0.i64(ptr align 4 %tmpInt1, i8 0, i64 4, i1 false)
call void @llvm.memcpy.p0.p0.i64(ptr align 4 %tmpInt2, ptr align 4 %tmpInt1, i64 4, i1 false)
call void @llvm.memmove.p0.p0.i64(ptr align 4 %tmpInt3, ptr align 4 %tmpInt1, i64 4, i1 false)
%cmpAddr = icmp ule ptr %tmpInt1, %tmpInt2
%addr1 = ptrtoint ptr %tmpInt1 to i64
%addr2 = ptrtoint ptr %tmpInt2 to i64
%subAddr = sub i64 %addr1, %addr2
store i64 0, ptr %ptrParam, align 1
%cmp = icmp ne i64 %subAddr, 0
br i1 %cmp, label %ehexit, label %noreturncall
noreturncall:
call void @NoReturn(ptr null, ptr null) noreturn [ "funclet"(token %0) ]
unreachable
ehexit:
cleanupret from %0 unwind to caller
; Ensure unreachable basic block doesn't make the compiler assert, as it's a special case for coloring computation.
nopredecessor:
call void @llvm.memset.p0.i64(ptr align 4 %tmpInt1, i8 0, i64 4, i1 false)
unreachable
}
; Non-Windows personality, ensure no funclet gets attached to asan runtime call.
define void @OtherPersonality(ptr %ptrParam) sanitize_address personality ptr @dummyPersonality {
; CHECK-LABEL: define void @OtherPersonality(
; CHECK-SAME: ptr [[PTRPARAM:%.*]]) #[[ATTR3:[0-9]+]] personality ptr @dummyPersonality {
; CHECK-NEXT: entry:
; CHECK-NEXT: [[TMP0:%.*]] = load i64, ptr @__asan_shadow_memory_dynamic_address, align 8
; CHECK-NEXT: [[ASAN_LOCAL_STACK_BASE:%.*]] = alloca i64, align 8
; CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr @__asan_option_detect_stack_use_after_return, align 4
; CHECK-NEXT: [[TMP2:%.*]] = icmp ne i32 [[TMP1]], 0
; CHECK-NEXT: br i1 [[TMP2]], label [[TMP3:%.*]], label [[TMP5:%.*]]
; CHECK: 3:
; CHECK-NEXT: [[TMP4:%.*]] = call i64 @__asan_stack_malloc_0(i64 64)
; CHECK-NEXT: br label [[TMP5]]
; CHECK: 5:
; CHECK-NEXT: [[TMP6:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[TMP4]], [[TMP3]] ]
; CHECK-NEXT: [[TMP7:%.*]] = icmp eq i64 [[TMP6]], 0
; CHECK-NEXT: br i1 [[TMP7]], label [[TMP8:%.*]], label [[TMP10:%.*]]
; CHECK: 8:
; CHECK-NEXT: [[MYALLOCA:%.*]] = alloca i8, i64 64, align 32
; CHECK-NEXT: [[TMP9:%.*]] = ptrtoint ptr [[MYALLOCA]] to i64
; CHECK-NEXT: br label [[TMP10]]
; CHECK: 10:
; CHECK-NEXT: [[TMP11:%.*]] = phi i64 [ [[TMP6]], [[TMP5]] ], [ [[TMP9]], [[TMP8]] ]
; CHECK-NEXT: store i64 [[TMP11]], ptr [[ASAN_LOCAL_STACK_BASE]], align 8
; CHECK-NEXT: [[TMP12:%.*]] = add i64 [[TMP11]], 32
; CHECK-NEXT: [[TMP13:%.*]] = inttoptr i64 [[TMP12]] to ptr
; CHECK-NEXT: [[TMP14:%.*]] = inttoptr i64 [[TMP11]] to ptr
; CHECK-NEXT: store i64 1102416563, ptr [[TMP14]], align 8
; CHECK-NEXT: [[TMP15:%.*]] = add i64 [[TMP11]], 8
; CHECK-NEXT: [[TMP16:%.*]] = inttoptr i64 [[TMP15]] to ptr
; CHECK-NEXT: store i64 ptrtoint (ptr @___asan_gen_stack.1 to i64), ptr [[TMP16]], align 8
; CHECK-NEXT: [[TMP17:%.*]] = add i64 [[TMP11]], 16
; CHECK-NEXT: [[TMP18:%.*]] = inttoptr i64 [[TMP17]] to ptr
; CHECK-NEXT: store i64 ptrtoint (ptr @OtherPersonality to i64), ptr [[TMP18]], align 8
; CHECK-NEXT: [[TMP19:%.*]] = lshr i64 [[TMP11]], 3
; CHECK-NEXT: [[TMP20:%.*]] = add i64 [[TMP19]], [[TMP0]]
; CHECK-NEXT: [[TMP21:%.*]] = add i64 [[TMP20]], 0
; CHECK-NEXT: call void @__asan_set_shadow_f1(i64 [[TMP21]], i64 4)
; CHECK-NEXT: [[TMP22:%.*]] = add i64 [[TMP20]], 4
; CHECK-NEXT: call void @__asan_set_shadow_04(i64 [[TMP22]], i64 1)
; CHECK-NEXT: [[TMP23:%.*]] = add i64 [[TMP20]], 5
; CHECK-NEXT: call void @__asan_set_shadow_f3(i64 [[TMP23]], i64 3)
; CHECK-NEXT: invoke void @MayThrowFunc()
; CHECK-NEXT: to label [[INVOKE_CONT:%.*]] unwind label [[EHCLEANUP:%.*]]
; CHECK: invoke.cont:
; CHECK-NEXT: store i64 1172321806, ptr [[TMP14]], align 8
; CHECK-NEXT: [[TMP24:%.*]] = icmp ne i64 [[TMP6]], 0
; CHECK-NEXT: br i1 [[TMP24]], label [[TMP25:%.*]], label [[TMP26:%.*]]
; CHECK: 25:
; CHECK-NEXT: call void @__asan_stack_free_0(i64 [[TMP6]], i64 64)
; CHECK-NEXT: br label [[TMP28:%.*]]
; CHECK: 26:
; CHECK-NEXT: [[TMP27:%.*]] = add i64 [[TMP20]], 0
; CHECK-NEXT: call void @__asan_set_shadow_00(i64 [[TMP27]], i64 8)
; CHECK-NEXT: br label [[TMP28]]
; CHECK: 28:
; CHECK-NEXT: ret void
; CHECK: ehcleanup:
; CHECK-NEXT: [[TMP29:%.*]] = cleanuppad within none []
; CHECK-NEXT: [[TMP30:%.*]] = call ptr @__asan_memset(ptr [[TMP13]], i32 0, i64 4)
; CHECK-NEXT: store i64 1172321806, ptr [[TMP14]], align 8
; CHECK-NEXT: [[TMP31:%.*]] = icmp ne i64 [[TMP6]], 0
; CHECK-NEXT: br i1 [[TMP31]], label [[TMP32:%.*]], label [[TMP33:%.*]]
; CHECK: 32:
; CHECK-NEXT: call void @__asan_stack_free_0(i64 [[TMP6]], i64 64)
; CHECK-NEXT: br label [[TMP35:%.*]]
; CHECK: 33:
; CHECK-NEXT: [[TMP34:%.*]] = add i64 [[TMP20]], 0
; CHECK-NEXT: call void @__asan_set_shadow_00(i64 [[TMP34]], i64 8)
; CHECK-NEXT: br label [[TMP35]]
; CHECK: 35:
; CHECK-NEXT: cleanupret from [[TMP29]] unwind to caller
;
entry:
%tmpInt = alloca i32, align 4
invoke void @MayThrowFunc()
to label %invoke.cont unwind label %ehcleanup
invoke.cont: ; preds = %entry
ret void
ehcleanup: ; preds = %entry
%0 = cleanuppad within none []
call void @llvm.memset.p0.i64(ptr align 4 %tmpInt, i8 0, i64 4, i1 false)
cleanupret from %0 unwind to caller
}
;.
; CHECK-INLINE: [[PROF1]] = !{!"branch_weights", i32 1, i32 1048575}
;.