Skip to content

Commit b96e647

Browse files
authored
[SYCL][NFC] Add more details why llvm.used need to be removed from the IR (#3012)
To address review comment #2995 (comment) Signed-off-by: Sergey Dmitriev <[email protected]>
1 parent b9f9fac commit b96e647

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

llvm/tools/sycl-post-link/sycl-post-link.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -689,9 +689,13 @@ int main(int argc, char **argv) {
689689
return 1;
690690
}
691691

692-
// Special "llvm.used" variable which holds references to global values in the
693-
// module is known to cause problems for tools which run later in pipeline, so
694-
// remove it from the module before perfroming any other actions.
692+
// After linking device bitcode "llvm.used" holds references to the kernels
693+
// that are defined in the device image. But after splitting device image into
694+
// separate kernels we may end up with having references to kernel declaration
695+
// originating from "llvm.used" in the IR that is passed to llvm-spirv tool,
696+
// and these declarations cause an assertion in llvm-spirv. To workaround this
697+
// issue remove "llvm.used" from the input module before performing any other
698+
// actions.
695699
if (GlobalVariable *GV = MPtr->getGlobalVariable("llvm.used")) {
696700
assert(GV->user_empty() && "unexpected llvm.used users");
697701
GV->eraseFromParent();

0 commit comments

Comments
 (0)