llvm.org GIT mirror llvm / caed319
[globalisel][tablegen] Fix PR32733 by checking which instruction operands belong to. canMutate() was returning true when the operands were all in the same order as the matched instruction. However, it wasn't checking the operands were actually on that instruction. This worked when we could only match a single instruction but the addition of nested instruction matching led to cases where the operands could be split across multiple instructions. canMutate() now returns false if operands belong to instructions other than the root of the match. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301077 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Sanders 3 years ago
2 changed file(s) with 68 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
0 # RUN: llc -mtriple=aarch64-- -run-pass=instruction-select -verify-machineinstrs -global-isel %s -o - | FileCheck %s
1
2 --- |
3 define i32 @main() {
4 entry:
5 ret i32 0
6 }
7
8 declare i32 @printf(i8*, ...)
9 ...
10 ---
11 # CHECK-LABEL: name: main
12 name: main
13 alignment: 2
14 exposesReturnsTwice: false
15 noVRegs: false
16 legalized: true
17 regBankSelected: true
18 selected: false
19 tracksRegLiveness: true
20 registers:
21 - { id: 0, class: gpr }
22 - { id: 1, class: gpr }
23 - { id: 2, class: gpr }
24 - { id: 3, class: gpr }
25 - { id: 4, class: gpr }
26 - { id: 5, class: gpr }
27 - { id: 6, class: gpr }
28 - { id: 7, class: gpr }
29 - { id: 8, class: gpr }
30 - { id: 9, class: gpr }
31 - { id: 10, class: gpr }
32 - { id: 11, class: gpr }
33 - { id: 12, class: gpr }
34 - { id: 13, class: gpr }
35 - { id: 14, class: gpr }
36 - { id: 15, class: gpr }
37 frameInfo:
38 isFrameAddressTaken: false
39 isReturnAddressTaken: false
40 hasStackMap: false
41 hasPatchPoint: false
42 stackSize: 0
43 offsetAdjustment: 0
44 maxAlignment: 8
45 adjustsStack: false
46 hasCalls: true
47 maxCallFrameSize: 0
48 hasOpaqueSPAdjustment: false
49 hasVAStart: false
50 hasMustTailInVarArgFunc: false
51 # CHECK: body:
52 # CHECK: %1 = COPY %w0
53 # CHECK-NOT: %2 = ORNWrr %wzr, %1
54 # CHECK: %4 = EONWrr %1, %3
55 body: |
56 bb.1.entry:
57 liveins: %w0
58 %0(s32) = G_CONSTANT i32 -1
59 %3(s32) = G_CONSTANT i32 1
60 %1(s32) = COPY %w0
61 %2(s32) = G_XOR %1, %0
62 %4(s32) = G_XOR %2, %3
63 %w0 = COPY %4(s32)
64 ...
10131013 bool canMutate() const {
10141014 for (const auto &Renderer : enumerate(OperandRenderers)) {
10151015 if (const auto *Copy = dyn_cast(&*Renderer.value())) {
1016 if (Matched.getOperand(Copy->getSymbolicName()).getOperandIndex() !=
1017 Renderer.index())
1016 const OperandMatcher &OM = Matched.getOperand(Copy->getSymbolicName());
1017 if (&Matched != &OM.getInstructionMatcher() ||
1018 OM.getOperandIndex() != Renderer.index())
10181019 return false;
10191020 } else
10201021 return false;