Bug Summary

File:lib/Target/Hexagon/MCTargetDesc/HexagonMCCompound.cpp
Warning:line 315, column 5
Called C++ object pointer is null

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name HexagonMCCompound.cpp -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-eagerly-assume -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -mrelocation-model pic -pic-level 2 -mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -momit-leaf-frame-pointer -ffunction-sections -fdata-sections -resource-dir /usr/lib/llvm-7/lib/clang/7.0.0 -D _DEBUG -D _GNU_SOURCE -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -I /build/llvm-toolchain-snapshot-7~svn325118/build-llvm/lib/Target/Hexagon/MCTargetDesc -I /build/llvm-toolchain-snapshot-7~svn325118/lib/Target/Hexagon/MCTargetDesc -I /build/llvm-toolchain-snapshot-7~svn325118/lib/Target/Hexagon -I /build/llvm-toolchain-snapshot-7~svn325118/build-llvm/lib/Target/Hexagon -I /build/llvm-toolchain-snapshot-7~svn325118/build-llvm/include -I /build/llvm-toolchain-snapshot-7~svn325118/include -U NDEBUG -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/x86_64-linux-gnu/c++/7.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/x86_64-linux-gnu/c++/7.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0/backward -internal-isystem /usr/include/clang/7.0.0/include/ -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-7/lib/clang/7.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -Wno-maybe-uninitialized -Wno-comment -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /build/llvm-toolchain-snapshot-7~svn325118/build-llvm/lib/Target/Hexagon/MCTargetDesc -ferror-limit 19 -fmessage-length 0 -fvisibility-inlines-hidden -fobjc-runtime=gcc -fdiagnostics-show-option -vectorize-loops -vectorize-slp -analyzer-checker optin.performance.Padding -analyzer-output=html -analyzer-config stable-report-filename=true -o /tmp/scan-build-2018-02-14-150435-17243-1 -x c++ /build/llvm-toolchain-snapshot-7~svn325118/lib/Target/Hexagon/MCTargetDesc/HexagonMCCompound.cpp
1//=== HexagonMCCompound.cpp - Hexagon Compound checker -------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file is looks at a packet and tries to form compound insns
11//
12//===----------------------------------------------------------------------===//
13
14#include "Hexagon.h"
15#include "MCTargetDesc/HexagonBaseInfo.h"
16#include "MCTargetDesc/HexagonMCInstrInfo.h"
17#include "MCTargetDesc/HexagonMCShuffler.h"
18#include "llvm/MC/MCContext.h"
19#include "llvm/MC/MCInst.h"
20#include "llvm/Support/Debug.h"
21#include "llvm/Support/ErrorHandling.h"
22#include "llvm/Support/raw_ostream.h"
23#include <cassert>
24#include <cstdint>
25
26using namespace llvm;
27using namespace Hexagon;
28
29#define DEBUG_TYPE"hexagon-mccompound" "hexagon-mccompound"
30
31enum OpcodeIndex {
32 fp0_jump_nt = 0,
33 fp0_jump_t,
34 fp1_jump_nt,
35 fp1_jump_t,
36 tp0_jump_nt,
37 tp0_jump_t,
38 tp1_jump_nt,
39 tp1_jump_t
40};
41
42static const unsigned tstBitOpcode[8] = {
43 J4_tstbit0_fp0_jump_nt, J4_tstbit0_fp0_jump_t, J4_tstbit0_fp1_jump_nt,
44 J4_tstbit0_fp1_jump_t, J4_tstbit0_tp0_jump_nt, J4_tstbit0_tp0_jump_t,
45 J4_tstbit0_tp1_jump_nt, J4_tstbit0_tp1_jump_t};
46static const unsigned cmpeqBitOpcode[8] = {
47 J4_cmpeq_fp0_jump_nt, J4_cmpeq_fp0_jump_t, J4_cmpeq_fp1_jump_nt,
48 J4_cmpeq_fp1_jump_t, J4_cmpeq_tp0_jump_nt, J4_cmpeq_tp0_jump_t,
49 J4_cmpeq_tp1_jump_nt, J4_cmpeq_tp1_jump_t};
50static const unsigned cmpgtBitOpcode[8] = {
51 J4_cmpgt_fp0_jump_nt, J4_cmpgt_fp0_jump_t, J4_cmpgt_fp1_jump_nt,
52 J4_cmpgt_fp1_jump_t, J4_cmpgt_tp0_jump_nt, J4_cmpgt_tp0_jump_t,
53 J4_cmpgt_tp1_jump_nt, J4_cmpgt_tp1_jump_t};
54static const unsigned cmpgtuBitOpcode[8] = {
55 J4_cmpgtu_fp0_jump_nt, J4_cmpgtu_fp0_jump_t, J4_cmpgtu_fp1_jump_nt,
56 J4_cmpgtu_fp1_jump_t, J4_cmpgtu_tp0_jump_nt, J4_cmpgtu_tp0_jump_t,
57 J4_cmpgtu_tp1_jump_nt, J4_cmpgtu_tp1_jump_t};
58static const unsigned cmpeqiBitOpcode[8] = {
59 J4_cmpeqi_fp0_jump_nt, J4_cmpeqi_fp0_jump_t, J4_cmpeqi_fp1_jump_nt,
60 J4_cmpeqi_fp1_jump_t, J4_cmpeqi_tp0_jump_nt, J4_cmpeqi_tp0_jump_t,
61 J4_cmpeqi_tp1_jump_nt, J4_cmpeqi_tp1_jump_t};
62static const unsigned cmpgtiBitOpcode[8] = {
63 J4_cmpgti_fp0_jump_nt, J4_cmpgti_fp0_jump_t, J4_cmpgti_fp1_jump_nt,
64 J4_cmpgti_fp1_jump_t, J4_cmpgti_tp0_jump_nt, J4_cmpgti_tp0_jump_t,
65 J4_cmpgti_tp1_jump_nt, J4_cmpgti_tp1_jump_t};
66static const unsigned cmpgtuiBitOpcode[8] = {
67 J4_cmpgtui_fp0_jump_nt, J4_cmpgtui_fp0_jump_t, J4_cmpgtui_fp1_jump_nt,
68 J4_cmpgtui_fp1_jump_t, J4_cmpgtui_tp0_jump_nt, J4_cmpgtui_tp0_jump_t,
69 J4_cmpgtui_tp1_jump_nt, J4_cmpgtui_tp1_jump_t};
70static const unsigned cmpeqn1BitOpcode[8] = {
71 J4_cmpeqn1_fp0_jump_nt, J4_cmpeqn1_fp0_jump_t, J4_cmpeqn1_fp1_jump_nt,
72 J4_cmpeqn1_fp1_jump_t, J4_cmpeqn1_tp0_jump_nt, J4_cmpeqn1_tp0_jump_t,
73 J4_cmpeqn1_tp1_jump_nt, J4_cmpeqn1_tp1_jump_t};
74static const unsigned cmpgtn1BitOpcode[8] = {
75 J4_cmpgtn1_fp0_jump_nt, J4_cmpgtn1_fp0_jump_t, J4_cmpgtn1_fp1_jump_nt,
76 J4_cmpgtn1_fp1_jump_t, J4_cmpgtn1_tp0_jump_nt, J4_cmpgtn1_tp0_jump_t,
77 J4_cmpgtn1_tp1_jump_nt, J4_cmpgtn1_tp1_jump_t,
78};
79
80// enum HexagonII::CompoundGroup
81static unsigned getCompoundCandidateGroup(MCInst const &MI, bool IsExtended) {
82 unsigned DstReg, SrcReg, Src1Reg, Src2Reg;
83
84 switch (MI.getOpcode()) {
85 default:
86 return HexagonII::HCG_None;
87 //
88 // Compound pairs.
89 // "p0=cmp.eq(Rs16,Rt16); if (p0.new) jump:nt #r9:2"
90 // "Rd16=#U6 ; jump #r9:2"
91 // "Rd16=Rs16 ; jump #r9:2"
92 //
93 case Hexagon::C2_cmpeq:
94 case Hexagon::C2_cmpgt:
95 case Hexagon::C2_cmpgtu:
96 if (IsExtended)
97 return false;
98 DstReg = MI.getOperand(0).getReg();
99 Src1Reg = MI.getOperand(1).getReg();
100 Src2Reg = MI.getOperand(2).getReg();
101 if ((Hexagon::P0 == DstReg || Hexagon::P1 == DstReg) &&
102 HexagonMCInstrInfo::isIntRegForSubInst(Src1Reg) &&
103 HexagonMCInstrInfo::isIntRegForSubInst(Src2Reg))
104 return HexagonII::HCG_A;
105 break;
106 case Hexagon::C2_cmpeqi:
107 case Hexagon::C2_cmpgti:
108 case Hexagon::C2_cmpgtui:
109 if (IsExtended)
110 return false;
111 // P0 = cmp.eq(Rs,#u2)
112 DstReg = MI.getOperand(0).getReg();
113 SrcReg = MI.getOperand(1).getReg();
114 if ((Hexagon::P0 == DstReg || Hexagon::P1 == DstReg) &&
115 HexagonMCInstrInfo::isIntRegForSubInst(SrcReg) &&
116 (HexagonMCInstrInfo::inRange<5>(MI, 2) ||
117 HexagonMCInstrInfo::minConstant(MI, 2) == -1))
118 return HexagonII::HCG_A;
119 break;
120 case Hexagon::A2_tfr:
121 if (IsExtended)
122 return false;
123 // Rd = Rs
124 DstReg = MI.getOperand(0).getReg();
125 SrcReg = MI.getOperand(1).getReg();
126 if (HexagonMCInstrInfo::isIntRegForSubInst(DstReg) &&
127 HexagonMCInstrInfo::isIntRegForSubInst(SrcReg))
128 return HexagonII::HCG_A;
129 break;
130 case Hexagon::A2_tfrsi:
131 if (IsExtended)
132 return false;
133 // Rd = #u6
134 DstReg = MI.getOperand(0).getReg();
135 if (HexagonMCInstrInfo::minConstant(MI, 1) <= 63 &&
136 HexagonMCInstrInfo::minConstant(MI, 1) >= 0 &&
137 HexagonMCInstrInfo::isIntRegForSubInst(DstReg))
138 return HexagonII::HCG_A;
139 break;
140 case Hexagon::S2_tstbit_i:
141 if (IsExtended)
142 return false;
143 DstReg = MI.getOperand(0).getReg();
144 Src1Reg = MI.getOperand(1).getReg();
145 if ((Hexagon::P0 == DstReg || Hexagon::P1 == DstReg) &&
146 HexagonMCInstrInfo::isIntRegForSubInst(Src1Reg) &&
147 HexagonMCInstrInfo::minConstant(MI, 2) == 0)
148 return HexagonII::HCG_A;
149 break;
150 // The fact that .new form is used pretty much guarantees
151 // that predicate register will match. Nevertheless,
152 // there could be some false positives without additional
153 // checking.
154 case Hexagon::J2_jumptnew:
155 case Hexagon::J2_jumpfnew:
156 case Hexagon::J2_jumptnewpt:
157 case Hexagon::J2_jumpfnewpt:
158 Src1Reg = MI.getOperand(0).getReg();
159 if (Hexagon::P0 == Src1Reg || Hexagon::P1 == Src1Reg)
160 return HexagonII::HCG_B;
161 break;
162 // Transfer and jump:
163 // Rd=#U6 ; jump #r9:2
164 // Rd=Rs ; jump #r9:2
165 // Do not test for jump range here.
166 case Hexagon::J2_jump:
167 case Hexagon::RESTORE_DEALLOC_RET_JMP_V4:
168 return HexagonII::HCG_C;
169 break;
170 }
171
172 return HexagonII::HCG_None;
173}
174
175/// getCompoundOp - Return the index from 0-7 into the above opcode lists.
176static unsigned getCompoundOp(MCInst const &HMCI) {
177 const MCOperand &Predicate = HMCI.getOperand(0);
178 unsigned PredReg = Predicate.getReg();
179
180 assert((PredReg == Hexagon::P0) || (PredReg == Hexagon::P1) ||(static_cast <bool> ((PredReg == Hexagon::P0) || (PredReg
== Hexagon::P1) || (PredReg == Hexagon::P2) || (PredReg == Hexagon
::P3)) ? void (0) : __assert_fail ("(PredReg == Hexagon::P0) || (PredReg == Hexagon::P1) || (PredReg == Hexagon::P2) || (PredReg == Hexagon::P3)"
, "/build/llvm-toolchain-snapshot-7~svn325118/lib/Target/Hexagon/MCTargetDesc/HexagonMCCompound.cpp"
, 181, __extension__ __PRETTY_FUNCTION__))
181 (PredReg == Hexagon::P2) || (PredReg == Hexagon::P3))(static_cast <bool> ((PredReg == Hexagon::P0) || (PredReg
== Hexagon::P1) || (PredReg == Hexagon::P2) || (PredReg == Hexagon
::P3)) ? void (0) : __assert_fail ("(PredReg == Hexagon::P0) || (PredReg == Hexagon::P1) || (PredReg == Hexagon::P2) || (PredReg == Hexagon::P3)"
, "/build/llvm-toolchain-snapshot-7~svn325118/lib/Target/Hexagon/MCTargetDesc/HexagonMCCompound.cpp"
, 181, __extension__ __PRETTY_FUNCTION__))
;
182
183 switch (HMCI.getOpcode()) {
184 default:
185 llvm_unreachable("Expected match not found.\n")::llvm::llvm_unreachable_internal("Expected match not found.\n"
, "/build/llvm-toolchain-snapshot-7~svn325118/lib/Target/Hexagon/MCTargetDesc/HexagonMCCompound.cpp"
, 185)
;
186 break;
187 case Hexagon::J2_jumpfnew:
188 return (PredReg == Hexagon::P0) ? fp0_jump_nt : fp1_jump_nt;
189 case Hexagon::J2_jumpfnewpt:
190 return (PredReg == Hexagon::P0) ? fp0_jump_t : fp1_jump_t;
191 case Hexagon::J2_jumptnew:
192 return (PredReg == Hexagon::P0) ? tp0_jump_nt : tp1_jump_nt;
193 case Hexagon::J2_jumptnewpt:
194 return (PredReg == Hexagon::P0) ? tp0_jump_t : tp1_jump_t;
195 }
196}
197
198static MCInst *getCompoundInsn(MCContext &Context, MCInst const &L,
199 MCInst const &R) {
200 MCInst *CompoundInsn = nullptr;
201 unsigned compoundOpcode;
202 MCOperand Rs, Rt;
203 int64_t Value;
204 bool Success;
205
206 switch (L.getOpcode()) {
47
Control jumps to 'case C2_cmpgtui:' at line 310
207 default:
208 DEBUG(dbgs() << "Possible compound ignored\n")do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("hexagon-mccompound")) { dbgs() << "Possible compound ignored\n"
; } } while (false)
;
209 return CompoundInsn;
210
211 case Hexagon::A2_tfrsi:
212 Rt = L.getOperand(0);
213 compoundOpcode = J4_jumpseti;
214 CompoundInsn = new (Context) MCInst;
215 CompoundInsn->setOpcode(compoundOpcode);
216
217 CompoundInsn->addOperand(Rt);
218 CompoundInsn->addOperand(L.getOperand(1)); // Immediate
219 CompoundInsn->addOperand(R.getOperand(0)); // Jump target
220 break;
221
222 case Hexagon::A2_tfr:
223 Rt = L.getOperand(0);
224 Rs = L.getOperand(1);
225
226 compoundOpcode = J4_jumpsetr;
227 CompoundInsn = new (Context) MCInst;
228 CompoundInsn->setOpcode(compoundOpcode);
229 CompoundInsn->addOperand(Rt);
230 CompoundInsn->addOperand(Rs);
231 CompoundInsn->addOperand(R.getOperand(0)); // Jump target.
232
233 break;
234
235 case Hexagon::C2_cmpeq:
236 DEBUG(dbgs() << "CX: C2_cmpeq\n")do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("hexagon-mccompound")) { dbgs() << "CX: C2_cmpeq\n"; }
} while (false)
;
237 Rs = L.getOperand(1);
238 Rt = L.getOperand(2);
239
240 compoundOpcode = cmpeqBitOpcode[getCompoundOp(R)];
241 CompoundInsn = new (Context) MCInst;
242 CompoundInsn->setOpcode(compoundOpcode);
243 CompoundInsn->addOperand(Rs);
244 CompoundInsn->addOperand(Rt);
245 CompoundInsn->addOperand(R.getOperand(1));
246 break;
247
248 case Hexagon::C2_cmpgt:
249 DEBUG(dbgs() << "CX: C2_cmpgt\n")do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("hexagon-mccompound")) { dbgs() << "CX: C2_cmpgt\n"; }
} while (false)
;
250 Rs = L.getOperand(1);
251 Rt = L.getOperand(2);
252
253 compoundOpcode = cmpgtBitOpcode[getCompoundOp(R)];
254 CompoundInsn = new (Context) MCInst;
255 CompoundInsn->setOpcode(compoundOpcode);
256 CompoundInsn->addOperand(Rs);
257 CompoundInsn->addOperand(Rt);
258 CompoundInsn->addOperand(R.getOperand(1));
259 break;
260
261 case Hexagon::C2_cmpgtu:
262 DEBUG(dbgs() << "CX: C2_cmpgtu\n")do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("hexagon-mccompound")) { dbgs() << "CX: C2_cmpgtu\n"; }
} while (false)
;
263 Rs = L.getOperand(1);
264 Rt = L.getOperand(2);
265
266 compoundOpcode = cmpgtuBitOpcode[getCompoundOp(R)];
267 CompoundInsn = new (Context) MCInst;
268 CompoundInsn->setOpcode(compoundOpcode);
269 CompoundInsn->addOperand(Rs);
270 CompoundInsn->addOperand(Rt);
271 CompoundInsn->addOperand(R.getOperand(1));
272 break;
273
274 case Hexagon::C2_cmpeqi:
275 DEBUG(dbgs() << "CX: C2_cmpeqi\n")do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("hexagon-mccompound")) { dbgs() << "CX: C2_cmpeqi\n"; }
} while (false)
;
276 Success = L.getOperand(2).getExpr()->evaluateAsAbsolute(Value);
277 (void)Success;
278 assert(Success)(static_cast <bool> (Success) ? void (0) : __assert_fail
("Success", "/build/llvm-toolchain-snapshot-7~svn325118/lib/Target/Hexagon/MCTargetDesc/HexagonMCCompound.cpp"
, 278, __extension__ __PRETTY_FUNCTION__))
;
279 if (Value == -1)
280 compoundOpcode = cmpeqn1BitOpcode[getCompoundOp(R)];
281 else
282 compoundOpcode = cmpeqiBitOpcode[getCompoundOp(R)];
283
284 Rs = L.getOperand(1);
285 CompoundInsn = new (Context) MCInst;
286 CompoundInsn->setOpcode(compoundOpcode);
287 CompoundInsn->addOperand(Rs);
288 CompoundInsn->addOperand(L.getOperand(2));
289 CompoundInsn->addOperand(R.getOperand(1));
290 break;
291
292 case Hexagon::C2_cmpgti:
293 DEBUG(dbgs() << "CX: C2_cmpgti\n")do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("hexagon-mccompound")) { dbgs() << "CX: C2_cmpgti\n"; }
} while (false)
;
294 Success = L.getOperand(2).getExpr()->evaluateAsAbsolute(Value);
295 (void)Success;
296 assert(Success)(static_cast <bool> (Success) ? void (0) : __assert_fail
("Success", "/build/llvm-toolchain-snapshot-7~svn325118/lib/Target/Hexagon/MCTargetDesc/HexagonMCCompound.cpp"
, 296, __extension__ __PRETTY_FUNCTION__))
;
297 if (Value == -1)
298 compoundOpcode = cmpgtn1BitOpcode[getCompoundOp(R)];
299 else
300 compoundOpcode = cmpgtiBitOpcode[getCompoundOp(R)];
301
302 Rs = L.getOperand(1);
303 CompoundInsn = new (Context) MCInst;
304 CompoundInsn->setOpcode(compoundOpcode);
305 CompoundInsn->addOperand(Rs);
306 CompoundInsn->addOperand(L.getOperand(2));
307 CompoundInsn->addOperand(R.getOperand(1));
308 break;
309
310 case Hexagon::C2_cmpgtui:
311 DEBUG(dbgs() << "CX: C2_cmpgtui\n")do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("hexagon-mccompound")) { dbgs() << "CX: C2_cmpgtui\n";
} } while (false)
;
312 Rs = L.getOperand(1);
313 compoundOpcode = cmpgtuiBitOpcode[getCompoundOp(R)];
314 CompoundInsn = new (Context) MCInst;
48
Null pointer value stored to 'CompoundInsn'
315 CompoundInsn->setOpcode(compoundOpcode);
49
Called C++ object pointer is null
316 CompoundInsn->addOperand(Rs);
317 CompoundInsn->addOperand(L.getOperand(2));
318 CompoundInsn->addOperand(R.getOperand(1));
319 break;
320
321 case Hexagon::S2_tstbit_i:
322 DEBUG(dbgs() << "CX: S2_tstbit_i\n")do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("hexagon-mccompound")) { dbgs() << "CX: S2_tstbit_i\n"
; } } while (false)
;
323 Rs = L.getOperand(1);
324 compoundOpcode = tstBitOpcode[getCompoundOp(R)];
325 CompoundInsn = new (Context) MCInst;
326 CompoundInsn->setOpcode(compoundOpcode);
327 CompoundInsn->addOperand(Rs);
328 CompoundInsn->addOperand(R.getOperand(1));
329 break;
330 }
331
332 return CompoundInsn;
333}
334
335/// Non-Symmetrical. See if these two instructions are fit for compound pair.
336static bool isOrderedCompoundPair(MCInst const &MIa, bool IsExtendedA,
337 MCInst const &MIb, bool IsExtendedB) {
338 unsigned MIaG = getCompoundCandidateGroup(MIa, IsExtendedA);
339 unsigned MIbG = getCompoundCandidateGroup(MIb, IsExtendedB);
340 // We have two candidates - check that this is the same register
341 // we are talking about.
342 unsigned Opca = MIa.getOpcode();
343 if (MIaG == HexagonII::HCG_A && MIbG == HexagonII::HCG_C &&
344 (Opca == Hexagon::A2_tfr || Opca == Hexagon::A2_tfrsi))
345 return true;
346 return ((MIaG == HexagonII::HCG_A && MIbG == HexagonII::HCG_B) &&
347 (MIa.getOperand(0).getReg() == MIb.getOperand(0).getReg()));
348}
349
350static bool lookForCompound(MCInstrInfo const &MCII, MCContext &Context,
351 MCInst &MCI) {
352 assert(HexagonMCInstrInfo::isBundle(MCI))(static_cast <bool> (HexagonMCInstrInfo::isBundle(MCI))
? void (0) : __assert_fail ("HexagonMCInstrInfo::isBundle(MCI)"
, "/build/llvm-toolchain-snapshot-7~svn325118/lib/Target/Hexagon/MCTargetDesc/HexagonMCCompound.cpp"
, 352, __extension__ __PRETTY_FUNCTION__))
;
353 bool JExtended = false;
354 for (MCInst::iterator J =
4
Loop condition is true. Entering loop body
9
Loop condition is true. Entering loop body
14
Loop condition is true. Entering loop body
19
Loop condition is true. Entering loop body
355 MCI.begin() + HexagonMCInstrInfo::bundleInstructionsOffset;
356 J != MCI.end(); ++J) {
357 MCInst const *JumpInst = J->getInst();
358 if (HexagonMCInstrInfo::isImmext(*JumpInst)) {
5
Assuming the condition is false
6
Taking false branch
10
Assuming the condition is false
11
Taking false branch
15
Assuming the condition is false
16
Taking false branch
20
Assuming the condition is false
21
Taking false branch
359 JExtended = true;
360 continue;
361 }
362 if (HexagonMCInstrInfo::getType(MCII, *JumpInst) == HexagonII::TypeJ) {
7
Assuming the condition is false
8
Taking false branch
12
Assuming the condition is false
13
Taking false branch
17
Assuming the condition is false
18
Taking false branch
22
Assuming the condition is true
23
Taking true branch
363 // Try to pair with another insn (B)undled with jump.
364 bool BExtended = false;
365 for (MCInst::iterator B =
24
Loop condition is true. Entering loop body
30
Loop condition is true. Entering loop body
36
Loop condition is true. Entering loop body
40
Loop condition is true. Entering loop body
366 MCI.begin() + HexagonMCInstrInfo::bundleInstructionsOffset;
367 B != MCI.end(); ++B) {
368 MCInst const *Inst = B->getInst();
369 if (JumpInst == Inst)
25
Assuming 'JumpInst' is not equal to 'Inst'
26
Taking false branch
31
Assuming 'JumpInst' is not equal to 'Inst'
32
Taking false branch
37
Assuming 'JumpInst' is equal to 'Inst'
38
Taking true branch
41
Assuming 'JumpInst' is not equal to 'Inst'
42
Taking false branch
370 continue;
39
Execution continues on line 367
371 if (HexagonMCInstrInfo::isImmext(*Inst)) {
27
Assuming the condition is false
28
Taking false branch
33
Assuming the condition is false
34
Taking false branch
43
Assuming the condition is false
44
Taking false branch
372 BExtended = true;
373 continue;
374 }
375 DEBUG(dbgs() << "J,B: " << JumpInst->getOpcode() << ","do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("hexagon-mccompound")) { dbgs() << "J,B: " << JumpInst
->getOpcode() << "," << Inst->getOpcode() <<
"\n"; } } while (false)
376 << Inst->getOpcode() << "\n")do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("hexagon-mccompound")) { dbgs() << "J,B: " << JumpInst
->getOpcode() << "," << Inst->getOpcode() <<
"\n"; } } while (false)
;
377 if (isOrderedCompoundPair(*Inst, BExtended, *JumpInst, JExtended)) {
29
Taking false branch
35
Taking false branch
45
Taking true branch
378 MCInst *CompoundInsn = getCompoundInsn(Context, *Inst, *JumpInst);
46
Calling 'getCompoundInsn'
379 if (CompoundInsn) {
380 DEBUG(dbgs() << "B: " << Inst->getOpcode() << ","do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("hexagon-mccompound")) { dbgs() << "B: " << Inst
->getOpcode() << "," << JumpInst->getOpcode
() << " Compounds to " << CompoundInsn->getOpcode
() << "\n"; } } while (false)
381 << JumpInst->getOpcode() << " Compounds to "do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("hexagon-mccompound")) { dbgs() << "B: " << Inst
->getOpcode() << "," << JumpInst->getOpcode
() << " Compounds to " << CompoundInsn->getOpcode
() << "\n"; } } while (false)
382 << CompoundInsn->getOpcode() << "\n")do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("hexagon-mccompound")) { dbgs() << "B: " << Inst
->getOpcode() << "," << JumpInst->getOpcode
() << " Compounds to " << CompoundInsn->getOpcode
() << "\n"; } } while (false)
;
383 J->setInst(CompoundInsn);
384 MCI.erase(B);
385 return true;
386 }
387 }
388 BExtended = false;
389 }
390 }
391 JExtended = false;
392 }
393 return false;
394}
395
396/// tryCompound - Given a bundle check for compound insns when one
397/// is found update the contents fo the bundle with the compound insn.
398/// If a compound instruction is found then the bundle will have one
399/// additional slot.
400void HexagonMCInstrInfo::tryCompound(MCInstrInfo const &MCII, MCSubtargetInfo const &STI,
401 MCContext &Context, MCInst &MCI) {
402 assert(HexagonMCInstrInfo::isBundle(MCI) &&(static_cast <bool> (HexagonMCInstrInfo::isBundle(MCI) &&
"Non-Bundle where Bundle expected") ? void (0) : __assert_fail
("HexagonMCInstrInfo::isBundle(MCI) && \"Non-Bundle where Bundle expected\""
, "/build/llvm-toolchain-snapshot-7~svn325118/lib/Target/Hexagon/MCTargetDesc/HexagonMCCompound.cpp"
, 403, __extension__ __PRETTY_FUNCTION__))
403 "Non-Bundle where Bundle expected")(static_cast <bool> (HexagonMCInstrInfo::isBundle(MCI) &&
"Non-Bundle where Bundle expected") ? void (0) : __assert_fail
("HexagonMCInstrInfo::isBundle(MCI) && \"Non-Bundle where Bundle expected\""
, "/build/llvm-toolchain-snapshot-7~svn325118/lib/Target/Hexagon/MCTargetDesc/HexagonMCCompound.cpp"
, 403, __extension__ __PRETTY_FUNCTION__))
;
404
405 // By definition a compound must have 2 insn.
406 if (MCI.size() < 2)
1
Assuming the condition is false
2
Taking false branch
407 return;
408
409 bool StartedValid = llvm::HexagonMCShuffle(Context, false, MCII, STI, MCI);
410
411 // Create a vector, needed to keep the order of jump instructions.
412 MCInst CheckList(MCI);
413
414 // Look for compounds until none are found, only update the bundle when
415 // a compound is found.
416 while (lookForCompound(MCII, Context, CheckList)) {
3
Calling 'lookForCompound'
417 // Keep the original bundle around in case the shuffle fails.
418 MCInst OriginalBundle(MCI);
419
420 // Need to update the bundle.
421 MCI = CheckList;
422
423 if (StartedValid &&
424 !llvm::HexagonMCShuffle(Context, false, MCII, STI, MCI)) {
425 DEBUG(dbgs() << "Found ERROR\n")do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType
("hexagon-mccompound")) { dbgs() << "Found ERROR\n"; } }
while (false)
;
426 MCI = OriginalBundle;
427 }
428 }
429}