-
Notifications
You must be signed in to change notification settings - Fork 219
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
Report error when finding variadic function other than printf #2703
Merged
MrSidims
merged 9 commits into
KhronosGroup:main
from
maarquitos14:maronas/unsupported_vararg_func
Sep 19, 2024
Merged
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
cc914c8
Report error when finding variadic function other than printf.
maarquitos14 69b156f
Adjust tests to new error.
maarquitos14 4b20355
Fix CI failure.
maarquitos14 8a6d75f
Address code review feedback.
maarquitos14 87a6179
Fix test.
maarquitos14 cbc9b10
Simplify condition to raise error.
maarquitos14 7bef74e
Fix error condition.
maarquitos14 13abd05
Fix assert condition.
maarquitos14 6d9585f
Address code review feedback.
maarquitos14 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 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 |
---|---|---|
|
@@ -814,6 +814,11 @@ SPIRVType *LLVMToSPIRVBase::transSPIRVOpaqueType(StringRef STName, | |
SPIRVType *LLVMToSPIRVBase::transScavengedType(Value *V) { | ||
if (auto *F = dyn_cast<Function>(V)) { | ||
FunctionType *FnTy = Scavenger->getFunctionType(F); | ||
// VarArg functions other than printf are not supported in SPIR-V. | ||
BM->getErrorLog().checkError( | ||
!(FnTy->isVarArg() && F->getName() != "printf"), | ||
SPIRVEC_UnsupportedVarArgFunction); | ||
|
||
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. LGTM! |
||
SPIRVType *RT = transType(FnTy->getReturnType()); | ||
std::vector<SPIRVType *> PT; | ||
for (Argument &Arg : F->args()) { | ||
|
This file contains 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
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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,20 @@ | ||
; Check whether the translator reports an error for a | ||
; function other than printf with variadic arguments. | ||
|
||
; RUN: llvm-as < %s -o %t.bc | ||
; RUN: not llvm-spirv %t.bc 2>&1 | FileCheck %s | ||
|
||
; ModuleID = 'unsupported_vararg_func.bc' | ||
source_filename = "llvm-link" | ||
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-G1" | ||
target triple = "spir64_x86_64" | ||
|
||
; CHECK: UnsupportedVarArgFunction: Variadic functions other than 'printf' are not supported in SPIR-V. | ||
; Function Attrs: convergent | ||
declare spir_func void @for__issue_diagnostic(i32 noundef, i32 noundef, ...) local_unnamed_addr | ||
|
||
define i32 @foo() nounwind { | ||
call spir_func void (i32, i32, ...) @for__issue_diagnostic(i32 noundef 41, i32 noundef 0) | ||
ret i32 0 | ||
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. two spaces before ret :) |
||
} | ||
|
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.
Is this test too strict? In the test array_of_matrices.ll, I see:
declare dso_local spir_func i32 @_Z18__spirv_ocl_printfPU3AS2Kcz(ptr addrspace(2), ...)
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 agree, there is mangling, and at least 3 names for the printf, so
F->getName() != "printf"
would not work properly.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 considered
F->getName().contains("printf")
, but thought that was too loose. What do you think, would that be better?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.
In SPIR-V Backend we have something along the lines of
so I guess as a first approach this could work after you've got
DemangledName
fromF->getName()
fromllvm::itaniumDemangle
.