| ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6 |
| ; RUN: opt < %s -passes=instcombine -S | FileCheck %s |
| |
| ; InstCombineLoadStoreAlloca replaced alloca uses with null when the |
| ; alloca size was poison. This causes invalid IR: |
| ; |
| ; call void @llvm.lifetime.start(ptr %i_) |
| ; becomes: |
| ; call void @llvm.lifetime.start(ptr null) |
| ; |
| ; According to the lifetime intrinsic spec, the argument must be either: |
| ; - A pointer to an alloca instruction, or |
| ; - A poison value. |
| ; |
| ; Since null is neither an alloca pointer nor poison, this transformation |
| ; produced invalid IR. |
| |
| define i32 @foo() { |
| ; CHECK-LABEL: define i32 @foo() { |
| ; CHECK-NEXT: [[ENTRY:.*:]] |
| ; CHECK-NEXT: store i32 0, ptr poison, align 4 |
| ; CHECK-NEXT: ret i32 0 |
| ; |
| entry: |
| %i_ = alloca i32, i32 poison, align 4 |
| call void @llvm.lifetime.start(ptr %i_) |
| store i32 0, ptr %i_, align 4 |
| ret i32 0 |
| } |