[llvm] [DirectX] Fix crash in DXILFlattenArrays for function declarations (PR #116690)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 18 12:16:51 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-directx
Author: Justin Bogner (bogner)
<details>
<summary>Changes</summary>
We were skipping intrinsics here, but really we need to skip all function declarations - if the function doesn't have a body there's nothing to walk.
---
Full diff: https://github.com/llvm/llvm-project/pull/116690.diff
2 Files Affected:
- (modified) llvm/lib/Target/DirectX/DXILFlattenArrays.cpp (+1-1)
- (modified) llvm/test/CodeGen/DirectX/flatten-array.ll (+3)
``````````diff
diff --git a/llvm/lib/Target/DirectX/DXILFlattenArrays.cpp b/llvm/lib/Target/DirectX/DXILFlattenArrays.cpp
index dec3a9b4a82643..e4a3bc76eeacd2 100644
--- a/llvm/lib/Target/DirectX/DXILFlattenArrays.cpp
+++ b/llvm/lib/Target/DirectX/DXILFlattenArrays.cpp
@@ -402,7 +402,7 @@ static bool flattenArrays(Module &M) {
DenseMap<GlobalVariable *, GlobalVariable *> GlobalMap;
flattenGlobalArrays(M, GlobalMap);
for (auto &F : make_early_inc_range(M.functions())) {
- if (F.isIntrinsic())
+ if (F.isDeclaration())
continue;
MadeChange |= Impl.visit(F);
}
diff --git a/llvm/test/CodeGen/DirectX/flatten-array.ll b/llvm/test/CodeGen/DirectX/flatten-array.ll
index fd894e0104c4e9..754d5a25ca905f 100644
--- a/llvm/test/CodeGen/DirectX/flatten-array.ll
+++ b/llvm/test/CodeGen/DirectX/flatten-array.ll
@@ -186,3 +186,6 @@ define void @global_gep_store() {
store i32 1, i32* %3, align 4
ret void
}
+
+; Make sure we don't try to walk the body of a function declaration.
+declare void @opaque_function()
``````````
</details>
https://github.com/llvm/llvm-project/pull/116690
More information about the llvm-commits
mailing list