forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[InstCombine] Don't check uses of constant exprs (llvm#113684)
This patch skips constant expressions to avoid iterating over uses on other functions. Fix crash reported in llvm#105510 (comment).
- Loading branch information
Showing
2 changed files
with
46 additions
and
1 deletion.
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
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,43 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: opt -S -passes=instcombine < %s | FileCheck %s | ||
|
||
; Make sure we don't crash in this case. | ||
@g = global i32 0 | ||
|
||
define i1 @foo() { | ||
; CHECK-LABEL: define i1 @foo() { | ||
; CHECK-NEXT: [[ENTRY:.*:]] | ||
; CHECK-NEXT: br i1 ptrtoint (ptr @g to i1), label %[[IF_THEN:.*]], label %[[IF_ELSE:.*]] | ||
; CHECK: [[IF_THEN]]: | ||
; CHECK-NEXT: ret i1 true | ||
; CHECK: [[IF_ELSE]]: | ||
; CHECK-NEXT: ret i1 false | ||
; | ||
entry: | ||
br i1 ptrtoint (ptr @g to i1), label %if.then, label %if.else | ||
|
||
if.then: | ||
ret i1 true | ||
|
||
if.else: | ||
ret i1 false | ||
} | ||
|
||
define i1 @bar() { | ||
; CHECK-LABEL: define i1 @bar() { | ||
; CHECK-NEXT: [[ENTRY:.*:]] | ||
; CHECK-NEXT: br i1 ptrtoint (ptr @g to i1), label %[[IF_THEN:.*]], label %[[IF_ELSE:.*]] | ||
; CHECK: [[IF_THEN]]: | ||
; CHECK-NEXT: ret i1 true | ||
; CHECK: [[IF_ELSE]]: | ||
; CHECK-NEXT: ret i1 false | ||
; | ||
entry: | ||
br i1 ptrtoint (ptr @g to i1), label %if.then, label %if.else | ||
|
||
if.then: | ||
ret i1 true | ||
|
||
if.else: | ||
ret i1 false | ||
} |