File: pr36228.ll

package info (click to toggle)
llvm-toolchain-13 1%3A13.0.1-11
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,418,840 kB
  • sloc: cpp: 5,290,826; ansic: 996,570; asm: 544,593; python: 188,212; objc: 72,027; lisp: 30,291; f90: 25,395; sh: 24,898; javascript: 9,780; pascal: 9,398; perl: 7,484; ml: 5,432; awk: 3,523; makefile: 2,913; xml: 953; cs: 573; fortran: 539
file content (40 lines) | stat: -rw-r--r-- 1,408 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
; RUN: opt -S -licm -o - %s | FileCheck %s
;
; Be sure that we don't hoist loads incorrectly if a loop has conditional UB.
; See PR36228.

declare void @check(i8)
declare void @llvm.memcpy.p0i8.p0i8.i64(i8*, i8*, i64, i32, i1)

; CHECK-LABEL: define void @buggy
define void @buggy(i8* %src, i1* %kOne) {
entry:
  %dst = alloca [1 x i8], align 1
  %0 = getelementptr inbounds [1 x i8], [1 x i8]* %dst, i64 0, i64 0
  store i8 42, i8* %0, align 1
  %src16 = bitcast i8* %src to i16*
  %srcval = load i16, i16* %src16
  br label %while.cond

while.cond:                                       ; preds = %if.end, %entry
  %dp.0 = phi i8* [ %0, %entry ], [ %dp.1, %if.end ]
  %1 = load volatile i1, i1* %kOne, align 4
  br i1 %1, label %if.else, label %if.then

if.then:                                          ; preds = %while.cond
  store i8 9, i8* %dp.0, align 1
  br label %if.end

if.else:                                          ; preds = %while.cond
  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %dp.0, i8* %src, i64 2, i32 1, i1 false)
  %dp.new = getelementptr inbounds i8, i8* %dp.0, i64 1
  br label %if.end

if.end:                                           ; preds = %if.else, %if.then
  %dp.1 = phi i8* [ %dp.0, %if.then ], [ %dp.new, %if.else ]
  ; CHECK: %2 = load i8, i8* %0
  %2 = load i8, i8* %0, align 1
  ; CHECK-NEXT: call void @check(i8 %2)
  call void @check(i8 %2)
  br label %while.cond
}