[PATCH] D104959: IR: Fix use-list-order round-tripping for br
Duncan P. N. Exon Smith via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 28 12:53:59 PDT 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb0d27eb06915: IR: Fix use-list-order round-tripping for br (authored by dexonsmith).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D104959/new/
https://reviews.llvm.org/D104959
Files:
llvm/lib/IR/Instructions.cpp
llvm/test/Assembler/br-single-destination.ll
Index: llvm/test/Assembler/br-single-destination.ll
===================================================================
--- /dev/null
+++ llvm/test/Assembler/br-single-destination.ll
@@ -0,0 +1,11 @@
+; RUN: llvm-as < %s -disable-output 2>&1 | FileCheck %s -allow-empty
+; CHECK-NOT: error
+; CHECK-NOT: warning
+; RUN: verify-uselistorder < %s
+
+define void @f1(i1 %cmp) {
+entry:
+ br i1 %cmp, label %branch, label %branch
+branch:
+ unreachable
+}
Index: llvm/lib/IR/Instructions.cpp
===================================================================
--- llvm/lib/IR/Instructions.cpp
+++ llvm/lib/IR/Instructions.cpp
@@ -1247,9 +1247,10 @@
: Instruction(Type::getVoidTy(IfTrue->getContext()), Instruction::Br,
OperandTraits<BranchInst>::op_end(this) - 3, 3,
InsertBefore) {
- Op<-1>() = IfTrue;
- Op<-2>() = IfFalse;
+ // Assign in order of operand index to make use-list order predictable.
Op<-3>() = Cond;
+ Op<-2>() = IfFalse;
+ Op<-1>() = IfTrue;
#ifndef NDEBUG
AssertOK();
#endif
@@ -1266,9 +1267,10 @@
BasicBlock *InsertAtEnd)
: Instruction(Type::getVoidTy(IfTrue->getContext()), Instruction::Br,
OperandTraits<BranchInst>::op_end(this) - 3, 3, InsertAtEnd) {
- Op<-1>() = IfTrue;
- Op<-2>() = IfFalse;
+ // Assign in order of operand index to make use-list order predictable.
Op<-3>() = Cond;
+ Op<-2>() = IfFalse;
+ Op<-1>() = IfTrue;
#ifndef NDEBUG
AssertOK();
#endif
@@ -1278,12 +1280,13 @@
: Instruction(Type::getVoidTy(BI.getContext()), Instruction::Br,
OperandTraits<BranchInst>::op_end(this) - BI.getNumOperands(),
BI.getNumOperands()) {
- Op<-1>() = BI.Op<-1>();
+ // Assign in order of operand index to make use-list order predictable.
if (BI.getNumOperands() != 1) {
assert(BI.getNumOperands() == 3 && "BR can have 1 or 3 operands!");
Op<-3>() = BI.Op<-3>();
Op<-2>() = BI.Op<-2>();
}
+ Op<-1>() = BI.Op<-1>();
SubclassOptionalData = BI.SubclassOptionalData;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104959.354998.patch
Type: text/x-patch
Size: 2075 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210628/81f28e0b/attachment.bin>
More information about the llvm-commits
mailing list