Skip to content

Commit f55fe9c

Browse files
farzonlIanWood1
authored andcommitted
[DirectX] Allow llvm lifetime intrinsics to pass on to the DirectX backend (llvm#136622)
fixes llvm#136620 It was determined that the lifetime intrinsics generated by clang are likely more correct than the ones in DXC hence explaining the missing lifetimes between the IR diffs. As such we are legalizing lllvm lifetime intrinsics by letting them all pass on through.
1 parent 392d5eb commit f55fe9c

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

llvm/lib/Target/DirectX/DXILOpLowering.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,8 @@ class OpLowerer {
753753
case Intrinsic::dx_resource_casthandle:
754754
// NOTE: llvm.dbg.value is supported as is in DXIL.
755755
case Intrinsic::dbg_value:
756+
case Intrinsic::lifetime_start:
757+
case Intrinsic::lifetime_end:
756758
case Intrinsic::not_intrinsic:
757759
continue;
758760
default: {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
; RUN: opt -S -passes='dxil-op-lower' -mtriple=dxil-pc-shadermodel6.3-library %s | FileCheck %s
2+
3+
; CHECK-LABEL: define void @test_legal_lifetime() {
4+
; CHECK-NEXT: [[ACCUM_I_FLAT:%.*]] = alloca [1 x i32], align 4
5+
; CHECK-NEXT: [[GEP:%.*]] = getelementptr i32, ptr [[ACCUM_I_FLAT]], i32 0
6+
; CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 4, ptr nonnull [[ACCUM_I_FLAT]])
7+
; CHECK-NEXT: store i32 0, ptr [[GEP]], align 4
8+
; CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 4, ptr nonnull [[ACCUM_I_FLAT]])
9+
; CHECK-NEXT: ret void
10+
;
11+
define void @test_legal_lifetime() {
12+
%accum.i.flat = alloca [1 x i32], align 4
13+
%gep = getelementptr i32, ptr %accum.i.flat, i32 0
14+
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %accum.i.flat)
15+
store i32 0, ptr %gep, align 4
16+
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %accum.i.flat)
17+
ret void
18+
}

0 commit comments

Comments
 (0)