brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.6 KiB · fa6a4a0 Raw
145 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 32; RUN: opt -O2 -S < %s | FileCheck %s3;4; Source code:5;   typedef unsigned long u64;6;   void foo(char *data, int idx, u64 *);7;   int test(int len, char *data) {8;     if (len < 100) {9;       for (int i = 1; i < len; i++) {10;         u64 d[1];11;         d[0] = data[0] ?: '0';12;         foo("%c", i, d);13;       }14;     }15;   return 0;16; }17; Compilation flag:18;   clang -target bpf -O2 -S -emit-llvm -Xclang -disable-llvm-passes test.c19 20; ModuleID = 'test.c'21source_filename = "test.c"22target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128"23target triple = "bpf"24 25@.str = private unnamed_addr constant [3 x i8] c"%c\00", align 126 27; Function Attrs: nounwind28define dso_local i32 @test(i32 %len, ptr %data) #0 {29; CHECK-LABEL: define dso_local noundef i32 @test(30; CHECK-SAME: i32 [[LEN:%.*]], ptr readonly captures(none) [[DATA:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {31; CHECK-NEXT:  entry:32; CHECK-NEXT:    [[D:%.*]] = alloca [1 x i64], align 833; CHECK-NEXT:    [[TMP0:%.*]] = add i32 [[LEN]], -234; CHECK-NEXT:    [[OR_COND:%.*]] = icmp ult i32 [[TMP0]], 9835; CHECK-NEXT:    br i1 [[OR_COND]], label [[FOR_BODY:%.*]], label [[IF_END:%.*]]36; CHECK:       for.body:37; CHECK-NEXT:    [[I_05:%.*]] = phi i32 [ [[INC:%.*]], [[FOR_BODY]] ], [ 1, [[ENTRY:%.*]] ]38; CHECK-NEXT:    call void @llvm.lifetime.start.p0(ptr nonnull [[D]]) #[[ATTR3:[0-9]+]]39; CHECK-NEXT:    [[TMP1:%.*]] = load i8, ptr [[DATA]], align 1, !tbaa [[TBAA3:![0-9]+]]40; CHECK-NEXT:    [[TOBOOL_NOT:%.*]] = icmp eq i8 [[TMP1]], 041; CHECK-NEXT:    [[NARROW:%.*]] = select i1 [[TOBOOL_NOT]], i8 48, i8 [[TMP1]]42; CHECK-NEXT:    [[CONV2:%.*]] = sext i8 [[NARROW]] to i6443; CHECK-NEXT:    store i64 [[CONV2]], ptr [[D]], align 8, !tbaa [[TBAA6:![0-9]+]]44; CHECK-NEXT:    call void @foo(ptr nonnull @.str, i32 [[I_05]], ptr nonnull [[D]]) #[[ATTR3]]45; CHECK-NEXT:    call void @llvm.lifetime.end.p0(ptr nonnull [[D]]) #[[ATTR3]]46; CHECK-NEXT:    [[INC]] = add nuw nsw i32 [[I_05]], 147; CHECK-NEXT:    [[EXITCOND_NOT:%.*]] = icmp eq i32 [[INC]], [[LEN]]48; CHECK-NEXT:    br i1 [[EXITCOND_NOT]], label [[IF_END]], label [[FOR_BODY]], !llvm.loop [[LOOP8:![0-9]+]]49; CHECK:       if.end:50; CHECK-NEXT:    ret i32 051;52entry:53  %len.addr = alloca i32, align 454  %data.addr = alloca ptr, align 855  %i = alloca i32, align 456  %d = alloca [1 x i64], align 857  store i32 %len, ptr %len.addr, align 4, !tbaa !358  store ptr %data, ptr %data.addr, align 8, !tbaa !759  %0 = load i32, ptr %len.addr, align 4, !tbaa !360  %cmp = icmp slt i32 %0, 10061  br i1 %cmp, label %if.then, label %if.end62 63if.then:                                          ; preds = %entry64  call void @llvm.lifetime.start.p0(ptr %i) #365  store i32 1, ptr %i, align 4, !tbaa !366  br label %for.cond67 68for.cond:                                         ; preds = %for.inc, %if.then69  %1 = load i32, ptr %i, align 4, !tbaa !370  %2 = load i32, ptr %len.addr, align 4, !tbaa !371  %cmp1 = icmp slt i32 %1, %272  br i1 %cmp1, label %for.body, label %for.cond.cleanup73 74 75for.cond.cleanup:                                 ; preds = %for.cond76  call void @llvm.lifetime.end.p0(ptr %i) #377  br label %for.end78 79for.body:                                         ; preds = %for.cond80  call void @llvm.lifetime.start.p0(ptr %d) #381  %3 = load ptr, ptr %data.addr, align 8, !tbaa !782  %4 = load i8, ptr %3, align 1, !tbaa !983  %conv = sext i8 %4 to i3284  %tobool = icmp ne i32 %conv, 085  br i1 %tobool, label %cond.true, label %cond.false86 87cond.true:                                        ; preds = %for.body88  br label %cond.end89 90cond.false:                                       ; preds = %for.body91  br label %cond.end92 93cond.end:                                         ; preds = %cond.false, %cond.true94  %cond = phi i32 [ %conv, %cond.true ], [ 48, %cond.false ]95  %conv2 = sext i32 %cond to i6496  store i64 %conv2, ptr %d, align 8, !tbaa !1097  %5 = load i32, ptr %i, align 4, !tbaa !398  call void @foo(ptr @.str, i32 %5, ptr %d)99  call void @llvm.lifetime.end.p0(ptr %d) #3100  br label %for.inc101 102for.inc:                                          ; preds = %cond.end103  %6 = load i32, ptr %i, align 4, !tbaa !3104  %inc = add nsw i32 %6, 1105  store i32 %inc, ptr %i, align 4, !tbaa !3106  br label %for.cond, !llvm.loop !12107 108for.end:                                          ; preds = %for.cond.cleanup109  br label %if.end110 111if.end:                                           ; preds = %for.end, %entry112  ret i32 0113}114 115; Function Attrs: argmemonly nofree nosync nounwind willreturn116declare void @llvm.lifetime.start.p0(ptr nocapture) #1117 118declare dso_local void @foo(ptr, i32, ptr) #2119 120; Function Attrs: argmemonly nofree nosync nounwind willreturn121declare void @llvm.lifetime.end.p0(ptr nocapture) #1122 123attributes #0 = { nounwind "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }124attributes #1 = { argmemonly nofree nosync nounwind willreturn }125attributes #2 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }126attributes #3 = { nounwind }127 128!llvm.module.flags = !{!0, !1}129!llvm.ident = !{!2}130 131!0 = !{i32 1, !"wchar_size", i32 4}132!1 = !{i32 7, !"frame-pointer", i32 2}133!2 = !{!"clang version 14.0.0 (https://github.com/llvm/llvm-project.git 8385de118443144518c9fba8b3d831d9076e746b)"}134!3 = !{!4, !4, i64 0}135!4 = !{!"int", !5, i64 0}136!5 = !{!"omnipotent char", !6, i64 0}137!6 = !{!"Simple C/C++ TBAA"}138!7 = !{!8, !8, i64 0}139!8 = !{!"any pointer", !5, i64 0}140!9 = !{!5, !5, i64 0}141!10 = !{!11, !11, i64 0}142!11 = !{!"long", !5, i64 0}143!12 = distinct !{!12, !13}144!13 = !{!"llvm.loop.mustprogress"}145