File: pr36228.ll

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (38 lines) | stat: -rw-r--r-- 1,307 bytes parent folder | download | duplicates (14)
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
; RUN: opt -S -passes=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.p0.p0.i64(ptr, ptr, i64, i32, i1)

; CHECK-LABEL: define void @buggy
define void @buggy(ptr %src, ptr %kOne) {
entry:
  %dst = alloca [1 x i8], align 1
  store i8 42, ptr %dst, align 1
  %srcval = load i16, ptr %src
  br label %while.cond

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

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

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

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