-
Notifications
You must be signed in to change notification settings - Fork 224
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
Translate nonsemantic attribute and metadata of GlobalVariable #2944
Conversation
Motivations is similar as f729c49. This PR addresses SYCL device global which may have attributes "sycl-device-image-scope", "sycl-host-access" and "sycl-unique-id". Failure to preserve "sycl-unique-id" after llvm-spirv translation triggers assert error at https://github.com/intel/llvm/blob/2824f61dd36790448a224cd596985bd01cbcd0f3/llvm/lib/SYCLLowerIR/DeviceGlobals.cpp#L85 Also preserve GlobalVariable metadata as an improvement, though there is no test to show this is really needed.
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, just have one nit/clarification question.
lib/SPIRV/SPIRVReader.cpp
Outdated
auto *GO = cast<GlobalObject>(getTranslatedValue(Arg0)); | ||
auto *F = dyn_cast_or_null<Function>(GO); | ||
auto *GV = dyn_cast_or_null<GlobalVariable>(GO); |
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 makes me a little bit suspicious, why do we need dyn_cast**_or_null** here when GO
is a result of a cast
? May be it's leftover from a previous patch iteration, where some test was failing.
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, yet it is a misuse.
lib/SPIRV/SPIRVWriter.cpp
Outdated
auto *BM = BF->getModule(); | ||
void LLVMToSPIRVBase::transAuxDataInst(SPIRVValue *BV, Value *V) { | ||
auto *GO = cast<GlobalObject>(V); | ||
auto *F = dyn_cast_or_null<Function>(GO); |
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.
Same question about _or_null
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
PreserveCount = 2 | ||
GlobalVariableMetadata = 2, | ||
GlobalVariableAttribute = 3, | ||
PreserveCount = 4 |
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.
If PreserveCount
is (and has been previously) unused it should be probably deleted entirely. Otherwise, this line introduces a concern about binary incompatibility due to changing PreserveCount
's value.
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.
deleted. It is unused.
Motivations is similar as f729c49. This PR addresses SYCL device global which may have attributes "sycl-device-image-scope", "sycl-host-access" and "sycl-unique-id". Failure to preserve "sycl-unique-id" after llvm-spirv translation triggers assert at
https://github.com/intel/llvm/blob/2824f61dd36790448a224cd596985bd01cbcd0f3/llvm/lib/SYCLLowerIR/DeviceGlobals.cpp#L85
Also preserve GlobalVariable metadata as an improvement, though there is no test to show this is really needed.