[llvm-dev] lifetime_start/end

Johannes Doerfert via llvm-dev llvm-dev at lists.llvm.org
Wed Sep 30 06:14:11 PDT 2020


lifetime markers should always be OK to remove, as you noted.

They restrict life ranges and removing them "just" makes the life ranges 
larger,
regardless if the variables are used or not.

That said, original code or the transformation you apply is probably
the reason for the non-determinism, it's impossible to say from a snipped
like this.

~ Johannes


On 9/30/20 4:28 AM, Abid Malik via llvm-dev wrote:
> Hello,
>
> What intrinsics "@llvm.lifetime.start/@llvm.lifetime.end" really do? As per
> my knowledge, they define the live ranges of variables. In the following
> code section, they seem redundant. However, when I remove them, the
> behavior of the code becomes non-deterministic. The live ranges of the
> variables defined by them are never used in the code.
>
> Thanks,
> ---------------
> %37 = bitcast i32* %7 to i8*
>    call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %37) #5
>    store i32 0, i32* %7, align 4, !tbaa !4
>    %38 = bitcast i32* %8 to i8*
>    call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %38) #5
>    store i32 99, i32* %8, align 4, !tbaa !4
>    %39 = bitcast i32* %9 to i8*
>    call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %39) #5
>    store i32 1, i32* %9, align 4, !tbaa !4
>    %40 = bitcast i32* %10 to i8*
>    call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %40) #5
>    store i32 0, i32* %10, align 4, !tbaa !4
>    call void @__kmpc_for_static_init_4(%struct.ident_t* nonnull @0, i32 %23,
> i32 34, i32* nonnull %10, i32* nonnull %7, i32* nonnull %8, i32* nonnull
> %9, i32 1, i32 1) #5
>    %41 = load i32, i32* %8, align 4, !tbaa !4
>    %42 = icmp slt i32 %41, 99
>    %43 = select i1 %42, i32 %41, i32 99
>    store i32 %43, i32* %8, align 4, !tbaa !4
>    %44 = load i32, i32* %7, align 4, !tbaa !4
>    br label %45
>
> 45:                                               ; preds = %49, %36
>    %46 = phi i32 [ %44, %36 ], [ %52, %49 ]
>    %47 = load i32, i32* %8, align 4, !tbaa !4
>    %48 = icmp sgt i32 %46, %47
>    br i1 %48, label %53, label %49
>
> 49:                                               ; preds = %45
>    %50 = shl nsw i32 %46, 1
>    %51 = call i32 (i8*, ...) @printf(i8* nonnull dereferenceable(1)
> getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32
> %50)
>    %52 = add nsw i32 %46, 1
>    br label %45
>
> 53:                                               ; preds = %45
>    call void @__kmpc_for_static_fini(%struct.ident_t* nonnull @0, i32 %23) #5
>    call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %40) #5
>    call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %39) #5
>    call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %38) #5
>    call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %37) #5
>    call void @__kmpc_barrier(%struct.ident_t* nonnull @1, i32 %23) #5
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev


More information about the llvm-dev mailing list