diff options
Diffstat (limited to 'interp/testdata/revert.ll')
-rw-r--r-- | interp/testdata/revert.ll | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/interp/testdata/revert.ll b/interp/testdata/revert.ll index dc6ee5c2a..517c152ba 100644 --- a/interp/testdata/revert.ll +++ b/interp/testdata/revert.ll @@ -3,6 +3,8 @@ target triple = "x86_64--linux" declare void @externalCall(i64) +declare i64 @ptrHash(i8* nocapture) + @foo.knownAtRuntime = global i64 0 @bar.knownAtRuntime = global i64 0 @baz.someGlobal = external global [3 x {i64, i32}] @@ -10,6 +12,8 @@ declare void @externalCall(i64) @x.atomicNum = global i32 0 @x.volatileNum = global i32 0 @y.ready = global i32 0 [email protected] = global i64 0 [email protected] = global [32 x i8] zeroinitializer define void @runtime.initAll() unnamed_addr { entry: @@ -19,6 +23,7 @@ entry: call void @main.init(i8* undef) call void @x.init(i8* undef) call void @y.init(i8* undef) + call void @z.init(i8* undef) ret void } @@ -72,3 +77,43 @@ loop: end: ret void } + +define internal void @z.init(i8* %context) unnamed_addr { + %bloom = bitcast i64* @z.bloom to i8* + + ; This can be safely expanded. + call void @z.setArr(i8* %bloom, i64 1, i8* %bloom) + + ; This call should be reverted to prevent unrolling. + call void @z.setArr(i8* bitcast ([32 x i8]* @z.arr to i8*), i64 32, i8* %bloom) + + ret void +} + +define internal void @z.setArr(i8* %arr, i64 %n, i8* %context) unnamed_addr { +entry: + br label %loop + +loop: + %prev = phi i64 [ %n, %entry ], [ %idx, %loop ] + %idx = sub i64 %prev, 1 + %elem = getelementptr i8, i8* %arr, i64 %idx + call void @z.set(i8* %elem, i8* %context) + %done = icmp eq i64 %idx, 0 + br i1 %done, label %end, label %loop + +end: + ret void +} + +define internal void @z.set(i8* %ptr, i8* %context) unnamed_addr { + ; Insert the pointer into the Bloom filter. + %hash = call i64 @ptrHash(i8* %ptr) + %index = lshr i64 %hash, 58 + %bit = shl i64 1, %index + %bloom = bitcast i8* %context to i64* + %old = load i64, i64* %bloom + %new = or i64 %old, %bit + store i64 %new, i64* %bloom + ret void +} |