Skip to content

Commit e0b522d

Browse files
authored
[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.
1 parent 5587627 commit e0b522d

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

llvm/lib/Target/DirectX/DXILFlattenArrays.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ static bool flattenArrays(Module &M) {
402402
DenseMap<GlobalVariable *, GlobalVariable *> GlobalMap;
403403
flattenGlobalArrays(M, GlobalMap);
404404
for (auto &F : make_early_inc_range(M.functions())) {
405-
if (F.isIntrinsic())
405+
if (F.isDeclaration())
406406
continue;
407407
MadeChange |= Impl.visit(F);
408408
}

llvm/test/CodeGen/DirectX/flatten-array.ll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,6 @@ define void @global_gep_store() {
186186
store i32 1, i32* %3, align 4
187187
ret void
188188
}
189+
190+
; Make sure we don't try to walk the body of a function declaration.
191+
declare void @opaque_function()

0 commit comments

Comments
 (0)