|
| 1 | +; RUN: opt -S -passes='sccp' %s -o %t1 |
| 2 | +; RUN: opt --bpf-check-undef-ir -S -mtriple=bpf-pc-linux %t1 >& %t2 |
| 3 | +; RUN: cat %t2 | FileCheck -check-prefixes=CHECK %s |
| 4 | + |
| 5 | +%union.v6addr = type { %struct.anon.1 } |
| 6 | +%struct.anon.1 = type { i64, i64 } |
| 7 | +%union.macaddr = type { %struct.anon } |
| 8 | +%struct.anon = type { i32, i16 } |
| 9 | +%struct.icmp6hdr = type { i8, i8, i16, %union.anon } |
| 10 | +%union.anon = type { [1 x i32] } |
| 11 | +%struct.ipv6_opt_hdr = type { i8, i8 } |
| 12 | + |
| 13 | +@repro.____fmt = internal constant [6 x i8] c"Start\00", align 1 |
| 14 | +@repro.____fmt.1 = internal constant [4 x i8] c"End\00", align 1 |
| 15 | +@__packed = dso_local global %union.v6addr zeroinitializer, align 8 |
| 16 | +@icmp6_ndisc_validate.____fmt = internal constant [23 x i8] c"pre ipv6_hdrlen_offset\00", align 1 |
| 17 | +@icmp6_ndisc_validate.____fmt.2 = internal constant [24 x i8] c"post ipv6_hdrlen_offset\00", align 1 |
| 18 | +@icmp6_ndisc_validate.____fmt.3 = internal constant [5 x i8] c"KO 1\00", align 1 |
| 19 | +@icmp6_ndisc_validate.____fmt.4 = internal constant [5 x i8] c"KO 2\00", align 1 |
| 20 | +@icmp6_ndisc_validate.____fmt.5 = internal constant [5 x i8] c"ACK \00", align 1 |
| 21 | +@ipv6_hdrlen_offset.____fmt = internal constant [17 x i8] c"OKOK %d, len: %d\00", align 1 |
| 22 | +@ipv6_hdrlen_offset.____fmt.6 = internal constant [18 x i8] c"KO INVALID EXTHDR\00", align 1 |
| 23 | +@llvm.compiler.used = appending global [1 x ptr] [ptr @repro], section "llvm.metadata" |
| 24 | + |
| 25 | +define dso_local i32 @repro(ptr noundef %0) section "classifier" { |
| 26 | + %2 = alloca %struct.ipv6_opt_hdr, align 8 |
| 27 | + %3 = tail call i64 (ptr, i32, ...) inttoptr (i64 6 to ptr)(ptr noundef nonnull @repro.____fmt, i32 noundef 6) |
| 28 | + %4 = tail call ptr asm sideeffect "$0 = *(u32 *)($1 + $2)", "=r,r,i"(ptr %0, i64 76) |
| 29 | + %5 = ptrtoint ptr %4 to i64 |
| 30 | + %6 = trunc i64 %5 to i32 |
| 31 | + %7 = tail call i64 (ptr, i32, ...) inttoptr (i64 6 to ptr)(ptr noundef nonnull @icmp6_ndisc_validate.____fmt, i32 noundef 23) |
| 32 | + call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %2) |
| 33 | + %8 = getelementptr inbounds nuw i8, ptr %2, i64 1 |
| 34 | + switch i8 undef, label %51 [ |
| 35 | + i8 59, label %56 |
| 36 | + i8 44, label %57 |
| 37 | + i8 0, label %9 |
| 38 | + i8 43, label %9 |
| 39 | + i8 51, label %9 |
| 40 | + i8 60, label %9 |
| 41 | + ] |
| 42 | + |
| 43 | +; CHECK: unreachable in func repro, due to uninitialized variable? |
| 44 | +; CHECK: %8 = getelementptr inbounds nuw i8, ptr %2, i64 1 |
| 45 | +; CHECK-NEXT: unreachable |
| 46 | + |
| 47 | +9: ; preds = %1, %1, %1, %1 |
| 48 | + %10 = sub i32 40, %6 |
| 49 | + %11 = call i64 inttoptr (i64 26 to ptr)(ptr noundef %0, i32 noundef %10, ptr noundef nonnull %2, i32 noundef 2) |
| 50 | + %12 = icmp slt i64 %11, 0 |
| 51 | + br i1 %12, label %57, label %13 |
| 52 | + |
| 53 | +13: ; preds = %9 |
| 54 | + %14 = load i8, ptr %8, align 1 |
| 55 | + %15 = zext i8 %14 to i32 |
| 56 | + %16 = shl nuw nsw i32 %15, 3 |
| 57 | + %17 = add nuw nsw i32 48, %16 |
| 58 | + %18 = load i8, ptr %2, align 1 |
| 59 | + switch i8 %18, label %51 [ |
| 60 | + i8 59, label %56 |
| 61 | + i8 44, label %57 |
| 62 | + i8 0, label %19 |
| 63 | + i8 43, label %19 |
| 64 | + i8 51, label %19 |
| 65 | + i8 60, label %19 |
| 66 | + ] |
| 67 | + |
| 68 | +19: ; preds = %13, %13, %13, %13 |
| 69 | + %20 = sub i32 %17, %6 |
| 70 | + %21 = call i64 inttoptr (i64 26 to ptr)(ptr noundef %0, i32 noundef %20, ptr noundef nonnull %2, i32 noundef 2) |
| 71 | + %22 = icmp slt i64 %21, 0 |
| 72 | + br i1 %22, label %57, label %23 |
| 73 | + |
| 74 | +23: ; preds = %19 |
| 75 | + %24 = icmp eq i8 %18, 51 |
| 76 | + %25 = load i8, ptr %8, align 1 |
| 77 | + %26 = zext i8 %25 to i32 |
| 78 | + %27 = select i1 %24, i32 2, i32 3 |
| 79 | + %28 = shl nuw nsw i32 %26, %27 |
| 80 | + %29 = add nuw nsw i32 %17, 8 |
| 81 | + %30 = add nuw nsw i32 %29, %28 |
| 82 | + %31 = load i8, ptr %2, align 1 |
| 83 | + switch i8 %31, label %51 [ |
| 84 | + i8 59, label %56 |
| 85 | + i8 44, label %57 |
| 86 | + i8 0, label %32 |
| 87 | + i8 43, label %32 |
| 88 | + i8 51, label %32 |
| 89 | + i8 60, label %32 |
| 90 | + ] |
| 91 | + |
| 92 | +32: ; preds = %23, %23, %23, %23 |
| 93 | + %33 = sub i32 %30, %6 |
| 94 | + %34 = call i64 inttoptr (i64 26 to ptr)(ptr noundef %0, i32 noundef %33, ptr noundef nonnull %2, i32 noundef 2) |
| 95 | + %35 = icmp slt i64 %34, 0 |
| 96 | + br i1 %35, label %57, label %36 |
| 97 | + |
| 98 | +36: ; preds = %32 |
| 99 | + %37 = icmp eq i8 %31, 51 |
| 100 | + %38 = load i8, ptr %8, align 1 |
| 101 | + %39 = zext i8 %38 to i32 |
| 102 | + %40 = select i1 %37, i32 2, i32 3 |
| 103 | + %41 = shl nuw nsw i32 %39, %40 |
| 104 | + %42 = add nuw nsw i32 %30, 8 |
| 105 | + %43 = add nuw nsw i32 %42, %41 |
| 106 | + %44 = load i8, ptr %2, align 1 |
| 107 | + switch i8 %44, label %51 [ |
| 108 | + i8 59, label %56 |
| 109 | + i8 44, label %57 |
| 110 | + i8 0, label %45 |
| 111 | + i8 43, label %45 |
| 112 | + i8 51, label %45 |
| 113 | + i8 60, label %45 |
| 114 | + ] |
| 115 | + |
| 116 | +45: ; preds = %36, %36, %36, %36 |
| 117 | + %46 = sub i32 %43, %6 |
| 118 | + %47 = call i64 inttoptr (i64 26 to ptr)(ptr noundef %0, i32 noundef %46, ptr noundef nonnull %2, i32 noundef 2) |
| 119 | + %48 = icmp slt i64 %47, 0 |
| 120 | + br i1 %48, label %57, label %49 |
| 121 | + |
| 122 | +49: ; preds = %45 |
| 123 | + %50 = call i64 (ptr, i32, ...) inttoptr (i64 6 to ptr)(ptr noundef nonnull @ipv6_hdrlen_offset.____fmt.6, i32 noundef 18) |
| 124 | + br label %59 |
| 125 | + |
| 126 | +51: ; preds = %36, %23, %13, %1 |
| 127 | + %52 = phi i8 [ undef, %1 ], [ %18, %13 ], [ %31, %23 ], [ %44, %36 ] |
| 128 | + %53 = phi i32 [ 40, %1 ], [ %17, %13 ], [ %30, %23 ], [ %43, %36 ] |
| 129 | + %54 = call i64 (ptr, i32, ...) inttoptr (i64 6 to ptr)(ptr noundef nonnull @ipv6_hdrlen_offset.____fmt, i32 noundef 17, i32 noundef 0, i32 noundef %53) |
| 130 | + %55 = icmp ne i8 %52, 58 |
| 131 | + br label %59 |
| 132 | + |
| 133 | +56: ; preds = %36, %23, %13, %1 |
| 134 | + br label %59 |
| 135 | + |
| 136 | +57: ; preds = %45, %36, %32, %23, %19, %13, %1, %9 |
| 137 | + %58 = phi i32 [ -134, %9 ], [ -157, %1 ], [ -157, %13 ], [ -134, %19 ], [ -157, %23 ], [ -134, %32 ], [ -157, %36 ], [ -134, %45 ] |
| 138 | + br label %59 |
| 139 | + |
| 140 | +59: ; preds = %57, %56, %51, %49 |
| 141 | + %60 = phi i1 [ %55, %51 ], [ undef, %49 ], [ undef, %56 ], [ undef, %57 ] |
| 142 | + %61 = phi i32 [ %53, %51 ], [ -156, %49 ], [ -156, %56 ], [ %58, %57 ] |
| 143 | + call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %2) |
| 144 | + %62 = call i64 (ptr, i32, ...) inttoptr (i64 6 to ptr)(ptr noundef nonnull @icmp6_ndisc_validate.____fmt.2, i32 noundef 24) |
| 145 | + %63 = icmp slt i32 %61, 0 |
| 146 | + %64 = or i1 %63, %60 |
| 147 | + br i1 %64, label %65, label %67 |
| 148 | + |
| 149 | +65: ; preds = %59 |
| 150 | + %66 = call i64 (ptr, i32, ...) inttoptr (i64 6 to ptr)(ptr noundef nonnull @icmp6_ndisc_validate.____fmt.3, i32 noundef 5) |
| 151 | + br label %77 |
| 152 | + |
| 153 | +67: ; preds = %59 |
| 154 | + %68 = call ptr asm sideeffect "$0 = *(u32 *)($1 + $2)", "=r,r,i"(ptr %0, i64 76) |
| 155 | + %69 = zext nneg i32 %61 to i64 |
| 156 | + %70 = getelementptr inbounds nuw i8, ptr %68, i64 %69 |
| 157 | + %71 = load i8, ptr %70, align 4 |
| 158 | + %72 = icmp eq i8 %71, -121 |
| 159 | + br i1 %72, label %75, label %73 |
| 160 | + |
| 161 | +73: ; preds = %67 |
| 162 | + %74 = call i64 (ptr, i32, ...) inttoptr (i64 6 to ptr)(ptr noundef nonnull @icmp6_ndisc_validate.____fmt.4, i32 noundef 5) |
| 163 | + br label %77 |
| 164 | + |
| 165 | +75: ; preds = %67 |
| 166 | + %76 = call i64 (ptr, i32, ...) inttoptr (i64 6 to ptr)(ptr noundef nonnull @icmp6_ndisc_validate.____fmt.5, i32 noundef 5) |
| 167 | + br label %77 |
| 168 | + |
| 169 | +77: ; preds = %65, %73, %75 |
| 170 | + %78 = call i64 (ptr, i32, ...) inttoptr (i64 6 to ptr)(ptr noundef nonnull @repro.____fmt.1, i32 noundef 4) |
| 171 | + ret i32 0 |
| 172 | +} |
0 commit comments