Skip to content

Commit fb0c50b

Browse files
committed
[MoveAutoInit] Gracefully handle auto-init annotation on unexpected instr (PR64661)
Abort the transform instead of asserting. Fixes llvm#64661.
1 parent 97c0df5 commit fb0c50b

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

llvm/lib/Transforms/Utils/MoveAutoInit.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static std::optional<MemoryLocation> writeToAlloca(const Instruction &I) {
5050
else if (auto *SI = dyn_cast<StoreInst>(&I))
5151
ML = MemoryLocation::get(SI);
5252
else
53-
assert(false && "memory location set");
53+
return std::nullopt;
5454

5555
if (isa<AllocaInst>(getUnderlyingObject(ML.Ptr)))
5656
return ML;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
2+
; RUN: opt -S -passes=move-auto-init < %s | FileCheck %s
3+
4+
define i1 @test(ptr %a, ptr %b) {
5+
; CHECK-LABEL: define i1 @test
6+
; CHECK-SAME: (ptr [[A:%.*]], ptr [[B:%.*]]) {
7+
; CHECK-NEXT: [[C:%.*]] = icmp uge ptr [[A]], [[B]], !annotation !0
8+
; CHECK-NEXT: ret i1 [[C]]
9+
;
10+
%c = icmp uge ptr %a, %b, !annotation !0
11+
ret i1 %c
12+
}
13+
14+
!0 = !{ !"auto-init" }

0 commit comments

Comments
 (0)