-
Notifications
You must be signed in to change notification settings - Fork 795
[DeviceSanitizer] Fix device global type of KernelMetadata #16357
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
Conversation
Hi @intel/dpcpp-tools-reviewers, please review, thanks! |
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.
lgtm
KernelMetadata->copyAttributesFrom(KernelMetadataOld); | ||
KernelMetadata->copyMetadata(KernelMetadataOld, 0); | ||
|
||
KernelMetadataOld->eraseFromParent(); |
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.
why not generate KernelMetadataOld in struct type in the first place?
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.
This is a good question.
"KernelMetadata" is an array with appending linkage, so it can't be struct type at beginning.
I also considered to generate "KernelMetadata" at sycl-post-link step completely, but I use "KernelMetadata" to distinguish if the device image is a sanitized module at the same time. If we don't add "KernelMetadata" at sanitizer pass, it's possible that a sanitized module (but without any sanitized kernels) won't enable sanitizer layer at UR.
This is a design decision that if user uses "-fsanitize=" to compile program, we will always enable sanitizer layer in UR.
Kindly ping @intel/dpcpp-tools-reviewers. Thanks! |
auto Name = KernelMetadata->getName().str(); | ||
KernelMetadata->setName(Name + "_del"); | ||
auto *KernelMetadataOld = KernelMetadata; |
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.
There is Value::takeName
which will simplify name transfer
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.
Done
M, StructTypeWithArray, false, GlobalValue::ExternalLinkage, | ||
ConstantStruct::get(StructTypeWithArray, | ||
KernelMetadataOld->getInitializer()), | ||
Name, nullptr, GlobalValue::NotThreadLocal, 1); |
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.
Would be good to have an inline comment explaining this magic 1
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.
Done
@intel/llvm-gatekeepers, please merge. Thanks! |
Kindly ping @intel/llvm-gatekeepers , please help merge the PR, thanks. |
OpenCL CPU requires the type of device global wraps with structure type