
Now that #149310 has restricted lifetime intrinsics to only work on allocas, we can also drop the explicit size argument. Instead, the size is implied by the alloca. This removes the ability to only mark a prefix of an alloca alive/dead. We never used that capability, so we should remove the need to handle that possibility everywhere (though many key places, including stack coloring, did not actually respect this).
65 lines
1.5 KiB
LLVM
65 lines
1.5 KiB
LLVM
; RUN: opt < %s -passes=instcombine -S | FileCheck %s
|
|
|
|
declare void @llvm.lifetime.start.p0(ptr nocapture)
|
|
declare void @llvm.lifetime.end.p0(ptr nocapture)
|
|
declare void @foo(ptr nocapture)
|
|
|
|
define void @asan() sanitize_address {
|
|
entry:
|
|
; CHECK-LABEL: @asan(
|
|
%text = alloca i8, align 1
|
|
|
|
call void @llvm.lifetime.start.p0(ptr %text)
|
|
call void @llvm.lifetime.end.p0(ptr %text)
|
|
; CHECK: call void @llvm.lifetime.start
|
|
; CHECK-NEXT: call void @llvm.lifetime.end
|
|
|
|
call void @foo(ptr %text) ; Keep alloca alive
|
|
|
|
ret void
|
|
}
|
|
|
|
define void @hwasan() sanitize_hwaddress {
|
|
entry:
|
|
; CHECK-LABEL: @hwasan(
|
|
%text = alloca i8, align 1
|
|
|
|
call void @llvm.lifetime.start.p0(ptr %text)
|
|
call void @llvm.lifetime.end.p0(ptr %text)
|
|
; CHECK: call void @llvm.lifetime.start
|
|
; CHECK-NEXT: call void @llvm.lifetime.end
|
|
|
|
call void @foo(ptr %text) ; Keep alloca alive
|
|
|
|
ret void
|
|
}
|
|
|
|
define void @msan() sanitize_memory {
|
|
entry:
|
|
; CHECK-LABEL: @msan(
|
|
%text = alloca i8, align 1
|
|
|
|
call void @llvm.lifetime.start.p0(ptr %text)
|
|
call void @llvm.lifetime.end.p0(ptr %text)
|
|
; CHECK: call void @llvm.lifetime.start
|
|
; CHECK-NEXT: call void @llvm.lifetime.end
|
|
|
|
call void @foo(ptr %text) ; Keep alloca alive
|
|
|
|
ret void
|
|
}
|
|
|
|
define void @no_asan() {
|
|
entry:
|
|
; CHECK-LABEL: @no_asan(
|
|
%text = alloca i8, align 1
|
|
|
|
call void @llvm.lifetime.start.p0(ptr %text)
|
|
call void @llvm.lifetime.end.p0(ptr %text)
|
|
; CHECK-NO: call void @llvm.lifetime
|
|
|
|
call void @foo(ptr %text) ; Keep alloca alive
|
|
|
|
ret void
|
|
}
|