xref: /llvm-project/llvm/test/CodeGen/WebAssembly/fast-isel-pr47040.ll (revision 115cb402d8ed91f94d22afcc4c2c9ed9def53cc7)
1; RUN: llc < %s -fast-isel -fast-isel-abort=1 -verify-machineinstrs
2
3; Regression test for PR47040, in which an assertion was improperly
4; triggered during FastISel's address computation. The issue was that
5; an `Address` set to be relative to FrameIndex zero was incorrectly
6; considered to have an unset base. When the left hand side of an add
7; set the Address to have a FrameIndex base of 0, the right side would
8; not detect that the Address base had already been set and could try
9; to set the Address to be relative to a register instead, triggering
10; an assertion.
11
12target triple = "wasm32-unknown-unknown"
13
14define i32 @foo() {
15  %stack_addr = alloca i32
16  %stack_i = ptrtoint ptr %stack_addr to i32
17  %added = add nuw i32 %stack_i, undef
18  %added_addr = inttoptr i32 %added to ptr
19  %ret = load i32, ptr %added_addr
20  ret i32 %ret
21}
22