Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SROA] Don't speculate phis with different load user types
Fixes an SROA crash. Fallout from opaque pointers since with typed pointers we'd bail out at the bitcast. Reviewed By: nikic Differential Revision: https://reviews.llvm.org/D136119
- Loading branch information
Showing
2 changed files
with
53 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
llvm/test/Transforms/SROA/phi-speculate-different-load-types.ll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py | ||
; RUN: opt -passes=sroa < %s -S | FileCheck %s | ||
|
||
define void @f(i1 %i) { | ||
; CHECK-LABEL: @f( | ||
; CHECK-NEXT: [[A1:%.*]] = alloca i64, align 8 | ||
; CHECK-NEXT: [[A2:%.*]] = alloca i64, align 8 | ||
; CHECK-NEXT: br i1 [[I:%.*]], label [[BB1:%.*]], label [[BB:%.*]] | ||
; CHECK: bb: | ||
; CHECK-NEXT: br label [[BB2:%.*]] | ||
; CHECK: bb1: | ||
; CHECK-NEXT: br label [[BB2]] | ||
; CHECK: bb2: | ||
; CHECK-NEXT: [[TMP3:%.*]] = phi ptr [ [[A1]], [[BB1]] ], [ [[A2]], [[BB]] ] | ||
; CHECK-NEXT: [[TMP5:%.*]] = load i32, ptr [[TMP3]], align 4 | ||
; CHECK-NEXT: [[TMP4:%.*]] = load i64, ptr [[TMP3]], align 4 | ||
; CHECK-NEXT: call void @use32(i32 [[TMP5]]) | ||
; CHECK-NEXT: call void @use64(i64 [[TMP4]]) | ||
; CHECK-NEXT: ret void | ||
; | ||
%a1 = alloca i64 | ||
%a2 = alloca i64 | ||
br i1 %i, label %bb1, label %bb | ||
|
||
bb: | ||
br label %bb2 | ||
|
||
bb1: | ||
br label %bb2 | ||
|
||
bb2: | ||
%tmp3 = phi ptr [ %a1, %bb1 ], [ %a2, %bb ] | ||
%tmp5 = load i32, ptr %tmp3 | ||
%tmp4 = load i64, ptr %tmp3 | ||
call void @use32(i32 %tmp5) | ||
call void @use64(i64 %tmp4) | ||
ret void | ||
} | ||
|
||
declare void @use32(i32) | ||
declare void @use64(i64) |