brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · 681c964 Raw
58 lines · plain
1; RUN: opt -passes=bpf-preserve-static-offset -mtriple=bpf-pc-linux -S -o - %s | FileCheck %s2;3; Check that loads from zero offset are not modified by bpf-preserve-static-offset.4;5; Source:6;    #define __ctx __attribute__((preserve_static_offset))7;    8;    struct foo {9;      int a;10;    } __ctx;11;    12;    extern void consume(int);13;    14;    void bar(struct foo *p) {15;      consume(p->a);16;    }17;18; Compilation flag:19;   clang -cc1 -O2 -triple bpf -S -emit-llvm -disable-llvm-passes -o - \20;       | opt -passes=function(sroa) -S -o -21 22%struct.foo = type { i32 }23 24; Function Attrs: nounwind25define dso_local void @bar(ptr noundef %p) #0 {26entry:27  %0 = call ptr @llvm.preserve.static.offset(ptr %p)28  %a = getelementptr inbounds %struct.foo, ptr %0, i32 0, i32 029  %1 = load i32, ptr %a, align 4, !tbaa !230  call void @consume(i32 noundef %1)31  ret void32}33 34; CHECK:      entry:35; CHECK-NEXT:   %[[a:.*]] = getelementptr inbounds %struct.foo, ptr %[[p:.*]], i32 0, i32 036; CHECK-NEXT:   %[[v2:.*]] = load i32, ptr %[[a]], align 4, !tbaa37; CHECK-NEXT:   call void @consume(i32 noundef %[[v2]])38 39declare void @consume(i32 noundef) #140 41; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)42declare ptr @llvm.preserve.static.offset(ptr readnone) #243 44attributes #0 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" }45attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" }46attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }47 48!llvm.module.flags = !{!0}49!llvm.ident = !{!1}50 51!0 = !{i32 1, !"wchar_size", i32 4}52!1 = !{!"clang"}53!2 = !{!3, !4, i64 0}54!3 = !{!"foo", !4, i64 0}55!4 = !{!"int", !5, i64 0}56!5 = !{!"omnipotent char", !6, i64 0}57!6 = !{!"Simple C/C++ TBAA"}58