-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[InferAddressSpaces] Handle llvm.lifetime #141045
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -passes=infer-address-spaces %s | FileCheck %s | ||
|
||
|
||
define i32 @lifetime_flat_pointer() { | ||
; CHECK-LABEL: define i32 @lifetime_flat_pointer() { | ||
; CHECK-NEXT: [[ALLOCA:%.*]] = alloca i32, align 4, addrspace(5) | ||
; CHECK-NEXT: call void @llvm.lifetime.start.p5(i64 4, ptr addrspace(5) [[ALLOCA]]) | ||
; CHECK-NEXT: store i32 1, ptr addrspace(5) [[ALLOCA]], align 4 | ||
; CHECK-NEXT: %ret = load i32, ptr addrspace(5) [[ALLOCA]], align 4 | ||
; CHECK-NEXT: call void @llvm.lifetime.end.p5(i64 4, ptr addrspace(5) [[ALLOCA]]) | ||
; CHECK-NEXT: ret i32 %ret | ||
; | ||
%alloca = alloca i32, align 4, addrspace(5) | ||
%flat = addrspacecast ptr addrspace(5) %alloca to ptr | ||
call void @llvm.lifetime.start.p0(i64 4 , ptr %flat) | ||
store i32 1, ptr %flat, align 4 | ||
%ret = load i32, ptr %flat, align 4 | ||
call void @llvm.lifetime.end.p0(i64 4 , ptr %flat) | ||
ret i32 %ret | ||
} | ||
|
||
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) | ||
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) |
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,42 @@ | ||||||||||||||||||
; RUN: opt -S -passes=infer-address-spaces %s | FileCheck %s | ||||||||||||||||||
|
||||||||||||||||||
QiYueFeiXue marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||
target triple = "nvptx64-nvidia-cuda" | ||||||||||||||||||
|
||||||||||||||||||
define i32 @lifetime_flat_pointer() { | ||||||||||||||||||
; CHECK-LABEL: define i32 @lifetime_flat_pointer() { | ||||||||||||||||||
; CHECK-NEXT: [[ALLOCA:%.*]] = alloca i32, align 4, addrspace(5) | ||||||||||||||||||
; CHECK-NEXT: call void @llvm.lifetime.start.p5(i64 4, ptr addrspace(5) [[ALLOCA]]) | ||||||||||||||||||
; CHECK-NEXT: store i32 1, ptr addrspace(5) [[ALLOCA]], align 4 | ||||||||||||||||||
; CHECK-NEXT: %ret = load i32, ptr addrspace(5) [[ALLOCA]], align 4 | ||||||||||||||||||
; CHECK-NEXT: call void @llvm.lifetime.end.p5(i64 4, ptr addrspace(5) [[ALLOCA]]) | ||||||||||||||||||
; CHECK-NEXT: ret i32 %ret | ||||||||||||||||||
; | ||||||||||||||||||
%alloca = alloca i32, align 4, addrspace(5) | ||||||||||||||||||
%flat = addrspacecast ptr addrspace(5) %alloca to ptr | ||||||||||||||||||
call void @llvm.lifetime.start.p0(i64 4 , ptr %flat) | ||||||||||||||||||
store i32 1, ptr %flat, align 4 | ||||||||||||||||||
%ret = load i32, ptr %flat, align 4 | ||||||||||||||||||
call void @llvm.lifetime.end.p0(i64 4 , ptr %flat) | ||||||||||||||||||
ret i32 %ret | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
define i32 @lifetime_flat_pointer2() { | ||||||||||||||||||
; CHECK-LABEL: define i32 @lifetime_flat_pointer2() { | ||||||||||||||||||
; CHECK-NEXT: [[ALLOCA:%.*]] = alloca i32, align 4 | ||||||||||||||||||
; CHECK-NEXT: [[TMP1:%.*]] = addrspacecast ptr [[ALLOCA]] to ptr addrspace(5) | ||||||||||||||||||
; CHECK-NEXT: call void @llvm.lifetime.start.p5(i64 4, ptr addrspace(5) [[TMP1]]) | ||||||||||||||||||
; CHECK-NEXT: store i32 1, ptr addrspace(5) [[TMP1]], align 4 | ||||||||||||||||||
; CHECK-NEXT: %ret = load i32, ptr addrspace(5) [[TMP1]], align 4 | ||||||||||||||||||
; CHECK-NEXT: call void @llvm.lifetime.end.p5(i64 4, ptr addrspace(5) [[TMP1]]) | ||||||||||||||||||
; CHECK-NEXT: ret i32 %ret | ||||||||||||||||||
; | ||||||||||||||||||
%alloca = alloca i32, align 4 | ||||||||||||||||||
call void @llvm.lifetime.start.p5(i64 4 , ptr %alloca) | ||||||||||||||||||
store i32 1, ptr %alloca, align 4 | ||||||||||||||||||
%ret = load i32, ptr %alloca, align 4 | ||||||||||||||||||
call void @llvm.lifetime.end.p5(i64 4 , ptr %alloca) | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The second one is a typo. Please check if it is needed in this scene. The following is the difference between IR before and after this PR:
before PR:
after PR:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, so it demonstrates a possible phase ordering with the alloca lowering PTX does, I suppose that's useful, if you adjust the test to look like this "before PR" version There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it, done, thanks |
||||||||||||||||||
ret i32 %ret | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) | ||||||||||||||||||
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) |
Uh oh!
There was an error while loading. Please reload this page.