brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1015 B · 2d39b3e Raw
23 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt < %s -mtriple i686-unknown-unknown -codegenprepare -S | FileCheck %s3 4target datalayout = "e-p:8:8"5 6; The shl has UB (shift count oob). This used to result in undefined behavior7; in codegenprepare when AddressingModeMatcher::matchOperationAddr tried to8; shift a variable by that amount during compilation. Intent with the test9; case is to verify that this compiles without complaints even if opt is built10; with ubsan enabled.11define dso_local void @main(i32 %a, ptr %p) {12; CHECK-LABEL: @main(13; CHECK-NEXT:    [[SHL:%.*]] = shl i32 [[A:%.*]], -122921676614; CHECK-NEXT:    [[ARRAYIDX926:%.*]] = getelementptr inbounds [3 x ptr], ptr [[P:%.*]], i32 0, i32 [[SHL]]15; CHECK-NEXT:    [[L0:%.*]] = load ptr, ptr [[ARRAYIDX926]], align 116; CHECK-NEXT:    ret void17;18  %shl = shl i32 %a, -122921676619  %arrayidx926 = getelementptr inbounds [3 x ptr], ptr %p, i32 0, i32 %shl20  %l0 = load ptr, ptr %arrayidx926, align 121  ret void22}23