brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.9 KiB · 308dc25 Raw
92 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt -passes=instcombine -S < %s | FileCheck %s3 4target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"5target triple = "x86_64-grtev4-linux-gnu"6 7define i32 @test_plain(i1 %f, ptr %a, ptr %b) {8; CHECK-LABEL: @test_plain(9; CHECK-NEXT:  entry:10; CHECK-NEXT:    [[B:%.*]] = select i1 [[F:%.*]], ptr [[A:%.*]], ptr [[B1:%.*]]11; CHECK-NEXT:    [[B_VAL:%.*]] = load i32, ptr [[B]], align 812; CHECK-NEXT:    ret i32 [[B_VAL]]13;14entry:15  %sel = select i1 %f, ptr %a, ptr %b16  %l = load i32, ptr %sel, align 817  ret i32 %l18}19 20; Don't speculate as the condition may control which memory is valid from21; sanitizer perspective.22define i32 @test_asan(i1 %f) sanitize_address {23; CHECK-LABEL: @test_asan(24; CHECK-NEXT:  entry:25; CHECK-NEXT:    [[A:%.*]] = alloca i32, align 826; CHECK-NEXT:    [[B:%.*]] = alloca i32, align 827; CHECK-NEXT:    [[SEL:%.*]] = select i1 [[F:%.*]], ptr [[A]], ptr [[B]]28; CHECK-NEXT:    [[L:%.*]] = load i32, ptr [[SEL]], align 829; CHECK-NEXT:    ret i32 [[L]]30;31entry:32  %a = alloca i32, align 833  %b = alloca i32, align 834  %sel = select i1 %f, ptr %a, ptr %b35  %l = load i32, ptr %sel, align 836  ret i32 %l37}38 39 40; Don't speculate as the condition may control which memory is valid from41; sanitizer perspective.42define i32 @test_hwasan(i1 %f) sanitize_hwaddress {43; CHECK-LABEL: @test_hwasan(44; CHECK-NEXT:  entry:45; CHECK-NEXT:    [[A:%.*]] = alloca i32, align 846; CHECK-NEXT:    [[B:%.*]] = alloca i32, align 847; CHECK-NEXT:    [[SEL:%.*]] = select i1 [[F:%.*]], ptr [[A]], ptr [[B]]48; CHECK-NEXT:    [[L:%.*]] = load i32, ptr [[SEL]], align 849; CHECK-NEXT:    ret i32 [[L]]50;51entry:52  %a = alloca i32, align 853  %b = alloca i32, align 854  %sel = select i1 %f, ptr %a, ptr %b55  %l = load i32, ptr %sel, align 856  ret i32 %l57}58 59; Don't speculate as the condition may control which memory is valid from60; sanitizer perspective.61define i32 @test_tsan(i1 %f) sanitize_thread {62; CHECK-LABEL: @test_tsan(63; CHECK-NEXT:  entry:64; CHECK-NEXT:    [[A:%.*]] = alloca i32, align 865; CHECK-NEXT:    [[B:%.*]] = alloca i32, align 866; CHECK-NEXT:    [[SEL:%.*]] = select i1 [[F:%.*]], ptr [[A]], ptr [[B]]67; CHECK-NEXT:    [[L:%.*]] = load i32, ptr [[SEL]], align 868; CHECK-NEXT:    ret i32 [[L]]69;70entry:71  %a = alloca i32, align 872  %b = alloca i32, align 873  %sel = select i1 %f, ptr %a, ptr %b74  %l = load i32, ptr %sel, align 875  ret i32 %l76}77 78; Msan just propagates shadow, even if speculated load accesses uninitialized79; value, instrumentation will select shadow of the desired value anyway.80define i32 @test_msan(i1 %f, ptr %a, ptr %b) sanitize_memory {81; CHECK-LABEL: @test_msan(82; CHECK-NEXT:  entry:83; CHECK-NEXT:    [[B:%.*]] = select i1 [[F:%.*]], ptr [[A:%.*]], ptr [[B1:%.*]]84; CHECK-NEXT:    [[B_VAL:%.*]] = load i32, ptr [[B]], align 885; CHECK-NEXT:    ret i32 [[B_VAL]]86;87entry:88  %sel = select i1 %f, ptr %a, ptr %b89  %l = load i32, ptr %sel, align 890  ret i32 %l91}92