| ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6 | |
| ; RUN: opt -passes=bpf-aspace-simplify -mtriple=bpf-pc-linux -S < %s | FileCheck %s | |
| ; Check that bpf-aspace-simplify pass does not use a cast after it erases it. | |
| ; %c is the outer cast of chain (%a, %b, %c) and the inner cast of | |
| ; chain (%c, %d, %e). The rewrite of the second chain erases %c. | |
| define dso_local ptr @test(ptr addrspace(1) %p) { | |
| ; CHECK-LABEL: define dso_local ptr @test( | |
| ; CHECK-SAME: ptr addrspace(1) [[P:%.*]]) { | |
| ; CHECK-NEXT: [[ENTRY:.*:]] | |
| ; CHECK-NEXT: [[A:%.*]] = addrspacecast ptr addrspace(1) [[P]] to ptr | |
| ; CHECK-NEXT: [[B:%.*]] = getelementptr inbounds i8, ptr [[A]], i64 8 | |
| ; CHECK-NEXT: [[D1:%.*]] = getelementptr inbounds i8, ptr [[B]], i64 4 | |
| ; CHECK-NEXT: ret ptr [[D1]] | |
| ; | |
| entry: | |
| %a = addrspacecast ptr addrspace(1) %p to ptr | |
| %b = getelementptr inbounds i8, ptr %a, i64 8 | |
| %c = addrspacecast ptr %b to ptr addrspace(1) | |
| %d = getelementptr inbounds i8, ptr addrspace(1) %c, i64 4 | |
| %e = addrspacecast ptr addrspace(1) %d to ptr | |
| ret ptr %e | |
| } |