| |
@@ -1,10 +1,11 @@
|
| |
- From cf54ca458afff1f7827bfbbc939429a00496c4f7 Mon Sep 17 00:00:00 2001
|
| |
- From: Tom Stellard <tstellar@redhat.com>
|
| |
- Date: Tue, 18 Aug 2020 10:54:49 -0700
|
| |
- Subject: [PATCH] [PowerPC] PPCBoolRetToInt: Skip translation if there is
|
| |
- ConstantExpr
|
| |
+ From cbea17568f4301582c1d5d43990f089ca6cff522 Mon Sep 17 00:00:00 2001
|
| |
+ From: Kai Luo <lkail@cn.ibm.com>
|
| |
+ Date: Fri, 28 Aug 2020 01:56:12 +0000
|
| |
+ Subject: [PATCH] [PowerPC] PPCBoolRetToInt: Don't translate Constant's
|
| |
+ operands
|
| |
|
| |
- PPCBoolRetToInt collects PHI, Argument, Call and Constant defs related to an `i1` value which later is translated to an `i32`/`i64` value. The `translate` method expects an `i1` value. However, if the `Constant` is a `ConstantExpr`, the type of the `ConstantExpr` might not be `i1`.
|
| |
+ When collecting `i1` values via `findAllDefs`, ignore Constant's
|
| |
+ operands, since Constant's operands might not be `i1`.
|
| |
|
| |
Fixes https://bugs.llvm.org/show_bug.cgi?id=46923 which causes ICE
|
| |
```
|
| |
@@ -13,15 +14,28 @@
|
| |
|
| |
Differential Revision: https://reviews.llvm.org/D85007
|
| |
---
|
| |
- llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp | 8 ++++--
|
| |
- llvm/test/CodeGen/PowerPC/pr46923.ll | 31 +++++++++++++++++++++
|
| |
- 2 files changed, 37 insertions(+), 2 deletions(-)
|
| |
+ llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp | 15 ++++++-----
|
| |
+ llvm/test/CodeGen/PowerPC/pr46923.ll | 29 +++++++++++++++++++++
|
| |
+ 2 files changed, 38 insertions(+), 6 deletions(-)
|
| |
create mode 100644 llvm/test/CodeGen/PowerPC/pr46923.ll
|
| |
|
| |
diff --git a/llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp b/llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp
|
| |
- index 2259a29f838..cfe3b3ce2e9 100644
|
| |
+ index acc8b317a22..172f1346c50 100644
|
| |
--- a/llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp
|
| |
+++ b/llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp
|
| |
+ @@ -78,9 +78,9 @@ class PPCBoolRetToInt : public FunctionPass {
|
| |
+ Value *Curr = WorkList.back();
|
| |
+ WorkList.pop_back();
|
| |
+ auto *CurrUser = dyn_cast<User>(Curr);
|
| |
+ - // Operands of CallInst are skipped because they may not be Bool type,
|
| |
+ - // and their positions are defined by ABI.
|
| |
+ - if (CurrUser && !isa<CallInst>(Curr))
|
| |
+ + // Operands of CallInst/Constant are skipped because they may not be Bool
|
| |
+ + // type. For CallInst, their positions are defined by ABI.
|
| |
+ + if (CurrUser && !isa<CallInst>(Curr) && !isa<Constant>(Curr))
|
| |
+ for (auto &Op : CurrUser->operands())
|
| |
+ if (Defs.insert(Op).second)
|
| |
+ WorkList.push_back(Op);
|
| |
@@ -90,6 +90,9 @@ class PPCBoolRetToInt : public FunctionPass {
|
| |
|
| |
// Translate a i1 value to an equivalent i32/i64 value:
|
| |
@@ -32,24 +46,25 @@
|
| |
Type *IntTy = ST->isPPC64() ? Type::getInt64Ty(V->getContext())
|
| |
: Type::getInt32Ty(V->getContext());
|
| |
|
| |
- @@ -227,8 +230,9 @@ class PPCBoolRetToInt : public FunctionPass {
|
| |
- // CallInst. Potentially, bitwise operations (AND, OR, XOR, NOT) and sign
|
| |
- // extension could also be handled in the future.
|
| |
- for (Value *V : Defs)
|
| |
- - if (!isa<PHINode>(V) && !isa<Constant>(V) &&
|
| |
- - !isa<Argument>(V) && !isa<CallInst>(V))
|
| |
- + if ((!isa<PHINode>(V) && !isa<Constant>(V) && !isa<Argument>(V) &&
|
| |
- + !isa<CallInst>(V)) ||
|
| |
- + isa<ConstantExpr>(V))
|
| |
- return false;
|
| |
-
|
| |
- for (Value *V : Defs)
|
| |
+ @@ -252,9 +255,9 @@ class PPCBoolRetToInt : public FunctionPass {
|
| |
+ auto *First = dyn_cast<User>(Pair.first);
|
| |
+ auto *Second = dyn_cast<User>(Pair.second);
|
| |
+ assert((!First || Second) && "translated from user to non-user!?");
|
| |
+ - // Operands of CallInst are skipped because they may not be Bool type,
|
| |
+ - // and their positions are defined by ABI.
|
| |
+ - if (First && !isa<CallInst>(First))
|
| |
+ + // Operands of CallInst/Constant are skipped because they may not be Bool
|
| |
+ + // type. For CallInst, their positions are defined by ABI.
|
| |
+ + if (First && !isa<CallInst>(First) && !isa<Constant>(First))
|
| |
+ for (unsigned i = 0; i < First->getNumOperands(); ++i)
|
| |
+ Second->setOperand(i, BoolToIntMap[First->getOperand(i)]);
|
| |
+ }
|
| |
diff --git a/llvm/test/CodeGen/PowerPC/pr46923.ll b/llvm/test/CodeGen/PowerPC/pr46923.ll
|
| |
new file mode 100644
|
| |
- index 00000000000..d6f65508848
|
| |
+ index 00000000000..3e9faa60422
|
| |
--- /dev/null
|
| |
+++ b/llvm/test/CodeGen/PowerPC/pr46923.ll
|
| |
- @@ -0,0 +1,31 @@
|
| |
+ @@ -0,0 +1,29 @@
|
| |
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
| |
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-unknown \
|
| |
+; RUN: -ppc-asm-full-reg-names < %s | FileCheck %s
|
| |
@@ -59,10 +74,8 @@
|
| |
+define i1 @foo() {
|
| |
+; CHECK-LABEL: foo:
|
| |
+; CHECK: # %bb.0: # %entry
|
| |
- +; CHECK-NEXT: crxor 4*cr5+lt, 4*cr5+lt, 4*cr5+lt
|
| |
+; CHECK-NEXT: li r3, 0
|
| |
- +; CHECK-NEXT: li r4, 1
|
| |
- +; CHECK-NEXT: isel r3, r4, r3, 4*cr5+lt
|
| |
+ +; CHECK-NEXT: isel r3, 0, r3, 4*cr5+lt
|
| |
+; CHECK-NEXT: blr
|
| |
+entry:
|
| |
+ br label %next
|
| |
@@ -82,5 +95,5 @@
|
| |
+ ret i1 %a
|
| |
+}
|
| |
--
|
| |
- 2.18.1
|
| |
+ 2.25.2
|
| |
|
| |