diff options
Diffstat (limited to 'llvm/test/Transforms/CodeGenPrepare/builtin-condition.ll')
-rw-r--r-- | llvm/test/Transforms/CodeGenPrepare/builtin-condition.ll | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/llvm/test/Transforms/CodeGenPrepare/builtin-condition.ll b/llvm/test/Transforms/CodeGenPrepare/builtin-condition.ll index e18d1b0fc0e..0d41e9e1edd 100644 --- a/llvm/test/Transforms/CodeGenPrepare/builtin-condition.ll +++ b/llvm/test/Transforms/CodeGenPrepare/builtin-condition.ll @@ -1,5 +1,38 @@ ; RUN: opt -codegenprepare -S < %s | FileCheck %s +; Ensure we act sanely on overflow. +; CHECK-LABEL: define i32 @bar +define i32 @bar() { +entry: + ; CHECK: ret i32 -1 + %az = alloca [2147483649 x i32], align 16 + %a = alloca i8*, align 8 + %arraydecay = getelementptr inbounds [2147483649 x i32], [2147483649 x i32]* %az, i32 0, i32 0 + %0 = bitcast i32* %arraydecay to i8* + store i8* %0, i8** %a, align 8 + %1 = load i8*, i8** %a, align 8 + %2 = call i32 @llvm.objectsize.i32.p0i8(i8* %1, i1 false) + ret i32 %2 +} + +; CHECK-LABEL: define i32 @baz +define i32 @baz(i32 %n) { +entry: + ; CHECK: ret i32 -1 + %az = alloca [1 x i32], align 16 + %bz = alloca [4294967297 x i32], align 16 + %tobool = icmp ne i32 %n, 0 + %arraydecay = getelementptr inbounds [1 x i32], [1 x i32]* %az, i64 0, i64 0 + %arraydecay1 = getelementptr inbounds [4294967297 x i32], [4294967297 x i32]* %bz, i64 0, i64 0 + %cond = select i1 %tobool, i32* %arraydecay, i32* %arraydecay1 + %0 = bitcast i32* %cond to i8* + %1 = call i32 @llvm.objectsize.i32.p0i8(i8* %0, i1 false) + ret i32 %1 +} + +declare i32 @llvm.objectsize.i32.p0i8(i8*, i1) + +; The following tests were generated by: ; #include<stdlib.h> ; #define STATIC_BUF_SIZE 10 ; #define LARGER_BUF_SIZE 30 @@ -87,4 +120,4 @@ entry: ret void } -declare i32 @printf(i8* nocapture readonly, ...)
\ No newline at end of file +declare i32 @printf(i8* nocapture readonly, ...) |