-
Notifications
You must be signed in to change notification settings - Fork 768
[SYCL] Do not crash if no matching store found #15658
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
llvm/test/SYCLLowerIR/printf_addrspace/no_matching_store.ll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
;; This test is derived from generic_as_variadic_no_opt.ll. | ||
;; This test ensures that when SYCLMutatePrintfAddrspace analyzes a load | ||
;; of the format pointer for a printf, it will not crash if a | ||
;; corresponding store is not found. | ||
|
||
; RUN: not opt < %s -passes=SYCLMutatePrintfAddrspace -S 2>&1 | FileCheck %s | ||
|
||
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64" | ||
target triple = "spir64-unknown-unknown" | ||
|
||
$_ZN2cl4sycl3ext6oneapi12experimental6printfIcJfEEEiPKT_DpT0_ = comdat any | ||
|
||
; CHECK: error: experimental::printf requires format string to reside in constant address space. The compiler wasn't able to automatically convert your format string into constant address space when processing builtin _Z18__spirv_ocl_printf{{.*}} called in function {{.*}}. | ||
|
||
; Function Attrs: convergent mustprogress noinline norecurse optnone | ||
define linkonce_odr dso_local spir_func i32 @_ZN2cl4sycl3ext6oneapi12experimental6printfIcJfEEEiPKT_DpT0_(ptr addrspace(4) %__format, float %args) #2 comdat { | ||
entry: | ||
%retval = alloca i32, align 4 | ||
%__format.addr = alloca ptr addrspace(4), align 8 | ||
%args.addr = alloca float, align 4 | ||
%retval.ascast = addrspacecast ptr %retval to ptr addrspace(4) | ||
%__format.addr.ascast = addrspacecast ptr %__format.addr to ptr addrspace(4) | ||
%args.addr.ascast = addrspacecast ptr %args.addr to ptr addrspace(4) | ||
; Remove store to ensure SYCLMutatePrintfAddrspace will not crash. | ||
; store ptr addrspace(4) %__format, ptr addrspace(4) %__format.addr.ascast, align 8 | ||
store float %args, ptr addrspace(4) %args.addr.ascast, align 4 | ||
%0 = load ptr addrspace(4), ptr addrspace(4) %__format.addr.ascast, align 8 | ||
%1 = load float, ptr addrspace(4) %args.addr.ascast, align 4 | ||
%call = call spir_func i32 (ptr addrspace(4), ...) @_Z18__spirv_ocl_printfPKcz(ptr addrspace(4) %0, float %1) #8 | ||
ret i32 %call | ||
} | ||
|
||
; Function Attrs: convergent | ||
declare dso_local spir_func i32 @_Z18__spirv_ocl_printfPKcz(ptr addrspace(4), ...) #7 | ||
|
||
attributes #2 = { convergent mustprogress noinline norecurse optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" } | ||
attributes #7 = { convergent "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" } | ||
attributes #8 = { convergent } | ||
|
||
!llvm.module.flags = !{!0, !1} | ||
!opencl.spir.version = !{!2} | ||
!spirv.Source = !{!3} | ||
|
||
!0 = !{i32 1, !"wchar_size", i32 4} | ||
!1 = !{i32 7, !"frame-pointer", i32 2} | ||
!2 = !{i32 1, i32 2} | ||
!3 = !{i32 4, i32 100000} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we hit a similar problem here?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's possible to have a problem. A store must have a value. SpecConstants.cpp has similar code:
V = Store->getValueOperand()->stripPointerCasts();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah ok yeah i see, thanks