[llvm] e0b522d - [DirectX] Fix crash in DXILFlattenArrays for function declarations (#116690)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 18 13:56:37 PST 2024
Author: Justin Bogner
Date: 2024-11-18T13:56:33-08:00
New Revision: e0b522dd94e48229d587a54a3103ba1c198b16a7
URL: https://github.com/llvm/llvm-project/commit/e0b522dd94e48229d587a54a3103ba1c198b16a7
DIFF: https://github.com/llvm/llvm-project/commit/e0b522dd94e48229d587a54a3103ba1c198b16a7.diff
LOG: [DirectX] Fix crash in DXILFlattenArrays for function declarations (#116690)
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.
Added:
Modified:
llvm/lib/Target/DirectX/DXILFlattenArrays.cpp
llvm/test/CodeGen/DirectX/flatten-array.ll
Removed:
################################################################################
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()
More information about the llvm-commits
mailing list