Skip to content

[ValueTracking] Remove faulty dereference of "InsertBefore" #85034

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

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/lib/Analysis/ValueTracking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5709,7 +5709,7 @@ llvm::FindInsertedValue(Value *V, ArrayRef<unsigned> idx_range,
// looking for, then.
if (*req_idx != *i)
return FindInsertedValue(I->getAggregateOperand(), idx_range,
*InsertBefore);
InsertBefore);
}
// If we end up here, the indices of the insertvalue match with those
// requested (though possibly only partially). Now we recursively look at
Expand Down
22 changes: 22 additions & 0 deletions llvm/test/Analysis/Lint/crash_empty_iterator.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
; RUN: opt -passes="lint" -S < %s | FileCheck %s

; After 2fe81edef6f0b
; [NFC][RemoveDIs] Insert instruction using iterators in Transforms/
; this crashed in FindInsertedValue when dereferencing an empty
; optional iterator.
; Just see that it doesn't crash anymore.

; CHECK-LABEL: @test1

%struct = type { i32, i32 }

define void @test1() {
entry:
%.fca.1.insert = insertvalue %struct zeroinitializer, i32 0, 1
%0 = extractvalue %struct %.fca.1.insert, 0
%1 = tail call %struct @foo(i32 %0)
ret void
}

declare %struct @foo(i32)