1 //===- llvm/unittests/tools/llvm-cfi-verify/FileAnalysis.cpp --------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "../tools/llvm-cfi-verify/lib/FileAnalysis.h"
11 #include "gmock/gmock.h"
12 #include "gtest/gtest.h"
14 #include "llvm/BinaryFormat/ELF.h"
15 #include "llvm/MC/MCAsmInfo.h"
16 #include "llvm/MC/MCContext.h"
17 #include "llvm/MC/MCDisassembler/MCDisassembler.h"
18 #include "llvm/MC/MCInst.h"
19 #include "llvm/MC/MCInstPrinter.h"
20 #include "llvm/MC/MCInstrAnalysis.h"
21 #include "llvm/MC/MCInstrDesc.h"
22 #include "llvm/MC/MCInstrInfo.h"
23 #include "llvm/MC/MCObjectFileInfo.h"
24 #include "llvm/MC/MCRegisterInfo.h"
25 #include "llvm/MC/MCSubtargetInfo.h"
26 #include "llvm/Object/Binary.h"
27 #include "llvm/Object/COFF.h"
28 #include "llvm/Object/ELFObjectFile.h"
29 #include "llvm/Object/ObjectFile.h"
30 #include "llvm/Support/Casting.h"
31 #include "llvm/Support/CommandLine.h"
32 #include "llvm/Support/Error.h"
33 #include "llvm/Support/MemoryBuffer.h"
34 #include "llvm/Support/TargetRegistry.h"
35 #include "llvm/Support/TargetSelect.h"
36 #include "llvm/Support/raw_ostream.h"
40 using Instr = ::llvm::cfi_verify::FileAnalysis::Instr;
42 using ::testing::Field;
45 namespace cfi_verify {
47 class ELFx86TestFileAnalysis : public FileAnalysis {
49 ELFx86TestFileAnalysis()
50 : FileAnalysis(Triple("x86_64--"), SubtargetFeatures()) {}
52 // Expose this method publicly for testing.
53 void parseSectionContents(ArrayRef<uint8_t> SectionBytes,
54 uint64_t SectionAddress) {
55 FileAnalysis::parseSectionContents(SectionBytes, SectionAddress);
58 Error initialiseDisassemblyMembers() {
59 return FileAnalysis::initialiseDisassemblyMembers();
63 class BasicFileAnalysisTest : public ::testing::Test {
65 virtual void SetUp() {
66 if (Analysis.initialiseDisassemblyMembers()) {
67 FAIL() << "Failed to initialise FileAnalysis.";
71 ELFx86TestFileAnalysis Analysis;
74 TEST_F(BasicFileAnalysisTest, BasicDisassemblyTraversalTest) {
75 Analysis.parseSectionContents(
78 0xb0, 0x00, // 1: mov $0x0, %al
79 0x48, 0x89, 0xe5, // 3: mov %rsp, %rbp
80 0x48, 0x83, 0xec, 0x18, // 6: sub $0x18, %rsp
81 0x48, 0xbe, 0xc4, 0x07, 0x40,
82 0x00, 0x00, 0x00, 0x00, 0x00, // 10: movabs $0x4007c4, %rsi
84 0x41, 0x0e, // 21: rex.B (bad)
85 0x62, 0x72, 0x65, 0x61, 0x6b, // 23: (bad) {%k1}
89 EXPECT_EQ(nullptr, Analysis.getInstruction(0x0));
90 EXPECT_EQ(nullptr, Analysis.getInstruction(0x1000));
93 const auto *InstrMeta = Analysis.getInstruction(0xDEADBEEF);
94 EXPECT_NE(nullptr, InstrMeta);
95 EXPECT_EQ(0xDEADBEEF, InstrMeta->VMAddress);
96 EXPECT_EQ(1u, InstrMeta->InstructionSize);
97 EXPECT_TRUE(InstrMeta->Valid);
99 const auto *NextInstrMeta = Analysis.getNextInstructionSequential(*InstrMeta);
100 EXPECT_EQ(nullptr, Analysis.getPrevInstructionSequential(*InstrMeta));
101 const auto *PrevInstrMeta = InstrMeta;
103 // 0xDEADBEEF + 1: mov $0x0, %al
104 InstrMeta = Analysis.getInstruction(0xDEADBEEF + 1);
105 EXPECT_NE(nullptr, InstrMeta);
106 EXPECT_EQ(NextInstrMeta, InstrMeta);
107 EXPECT_EQ(0xDEADBEEF + 1, InstrMeta->VMAddress);
108 EXPECT_EQ(2u, InstrMeta->InstructionSize);
109 EXPECT_TRUE(InstrMeta->Valid);
111 NextInstrMeta = Analysis.getNextInstructionSequential(*InstrMeta);
112 EXPECT_EQ(PrevInstrMeta, Analysis.getPrevInstructionSequential(*InstrMeta));
113 PrevInstrMeta = InstrMeta;
115 // 0xDEADBEEF + 3: mov %rsp, %rbp
116 InstrMeta = Analysis.getInstruction(0xDEADBEEF + 3);
117 EXPECT_NE(nullptr, InstrMeta);
118 EXPECT_EQ(NextInstrMeta, InstrMeta);
119 EXPECT_EQ(0xDEADBEEF + 3, InstrMeta->VMAddress);
120 EXPECT_EQ(3u, InstrMeta->InstructionSize);
121 EXPECT_TRUE(InstrMeta->Valid);
123 NextInstrMeta = Analysis.getNextInstructionSequential(*InstrMeta);
124 EXPECT_EQ(PrevInstrMeta, Analysis.getPrevInstructionSequential(*InstrMeta));
125 PrevInstrMeta = InstrMeta;
127 // 0xDEADBEEF + 6: sub $0x18, %rsp
128 InstrMeta = Analysis.getInstruction(0xDEADBEEF + 6);
129 EXPECT_NE(nullptr, InstrMeta);
130 EXPECT_EQ(NextInstrMeta, InstrMeta);
131 EXPECT_EQ(0xDEADBEEF + 6, InstrMeta->VMAddress);
132 EXPECT_EQ(4u, InstrMeta->InstructionSize);
133 EXPECT_TRUE(InstrMeta->Valid);
135 NextInstrMeta = Analysis.getNextInstructionSequential(*InstrMeta);
136 EXPECT_EQ(PrevInstrMeta, Analysis.getPrevInstructionSequential(*InstrMeta));
137 PrevInstrMeta = InstrMeta;
139 // 0xDEADBEEF + 10: movabs $0x4007c4, %rsi
140 InstrMeta = Analysis.getInstruction(0xDEADBEEF + 10);
141 EXPECT_NE(nullptr, InstrMeta);
142 EXPECT_EQ(NextInstrMeta, InstrMeta);
143 EXPECT_EQ(0xDEADBEEF + 10, InstrMeta->VMAddress);
144 EXPECT_EQ(10u, InstrMeta->InstructionSize);
145 EXPECT_TRUE(InstrMeta->Valid);
147 EXPECT_EQ(nullptr, Analysis.getNextInstructionSequential(*InstrMeta));
148 EXPECT_EQ(PrevInstrMeta, Analysis.getPrevInstructionSequential(*InstrMeta));
149 PrevInstrMeta = InstrMeta;
151 // 0xDEADBEEF + 20: (bad)
152 InstrMeta = Analysis.getInstruction(0xDEADBEEF + 20);
153 EXPECT_NE(nullptr, InstrMeta);
154 EXPECT_EQ(0xDEADBEEF + 20, InstrMeta->VMAddress);
155 EXPECT_EQ(1u, InstrMeta->InstructionSize);
156 EXPECT_FALSE(InstrMeta->Valid);
158 EXPECT_EQ(nullptr, Analysis.getNextInstructionSequential(*InstrMeta));
159 EXPECT_EQ(PrevInstrMeta, Analysis.getPrevInstructionSequential(*InstrMeta));
161 // 0xDEADBEEF + 21: rex.B (bad)
162 InstrMeta = Analysis.getInstruction(0xDEADBEEF + 21);
163 EXPECT_NE(nullptr, InstrMeta);
164 EXPECT_EQ(0xDEADBEEF + 21, InstrMeta->VMAddress);
165 EXPECT_EQ(2u, InstrMeta->InstructionSize);
166 EXPECT_FALSE(InstrMeta->Valid);
168 EXPECT_EQ(nullptr, Analysis.getNextInstructionSequential(*InstrMeta));
169 EXPECT_EQ(nullptr, Analysis.getPrevInstructionSequential(*InstrMeta));
171 // 0xDEADBEEF + 6: (bad) {%k1}
172 InstrMeta = Analysis.getInstruction(0xDEADBEEF + 23);
173 EXPECT_NE(nullptr, InstrMeta);
174 EXPECT_EQ(0xDEADBEEF + 23, InstrMeta->VMAddress);
175 EXPECT_EQ(5u, InstrMeta->InstructionSize);
176 EXPECT_FALSE(InstrMeta->Valid);
178 EXPECT_EQ(nullptr, Analysis.getNextInstructionSequential(*InstrMeta));
179 EXPECT_EQ(nullptr, Analysis.getPrevInstructionSequential(*InstrMeta));
182 TEST_F(BasicFileAnalysisTest, PrevAndNextFromBadInst) {
183 Analysis.parseSectionContents(
190 const auto &BadInstrMeta = Analysis.getInstructionOrDie(0xDEADBEEF + 1);
191 const auto *GoodInstrMeta =
192 Analysis.getPrevInstructionSequential(BadInstrMeta);
193 EXPECT_NE(nullptr, GoodInstrMeta);
194 EXPECT_EQ(0xDEADBEEF, GoodInstrMeta->VMAddress);
195 EXPECT_EQ(1u, GoodInstrMeta->InstructionSize);
197 GoodInstrMeta = Analysis.getNextInstructionSequential(BadInstrMeta);
198 EXPECT_NE(nullptr, GoodInstrMeta);
199 EXPECT_EQ(0xDEADBEEF + 2, GoodInstrMeta->VMAddress);
200 EXPECT_EQ(1u, GoodInstrMeta->InstructionSize);
203 TEST_F(BasicFileAnalysisTest, CFITrapTest) {
204 Analysis.parseSectionContents(
207 0xb0, 0x00, // 1: mov $0x0, %al
208 0x48, 0x89, 0xe5, // 3: mov %rsp, %rbp
209 0x48, 0x83, 0xec, 0x18, // 6: sub $0x18, %rsp
210 0x48, 0xbe, 0xc4, 0x07, 0x40,
211 0x00, 0x00, 0x00, 0x00, 0x00, // 10: movabs $0x4007c4, %rsi
213 0x41, 0x0e, // 21: rex.B (bad)
214 0x62, 0x72, 0x65, 0x61, 0x6b, // 23: (bad) {%k1}
215 0x0f, 0x0b // 28: ud2
219 EXPECT_FALSE(Analysis.isCFITrap(Analysis.getInstructionOrDie(0xDEADBEEF)));
221 Analysis.isCFITrap(Analysis.getInstructionOrDie(0xDEADBEEF + 3)));
223 Analysis.isCFITrap(Analysis.getInstructionOrDie(0xDEADBEEF + 6)));
225 Analysis.isCFITrap(Analysis.getInstructionOrDie(0xDEADBEEF + 10)));
227 Analysis.isCFITrap(Analysis.getInstructionOrDie(0xDEADBEEF + 20)));
229 Analysis.isCFITrap(Analysis.getInstructionOrDie(0xDEADBEEF + 21)));
231 Analysis.isCFITrap(Analysis.getInstructionOrDie(0xDEADBEEF + 23)));
233 Analysis.isCFITrap(Analysis.getInstructionOrDie(0xDEADBEEF + 28)));
236 TEST_F(BasicFileAnalysisTest, FallThroughTest) {
237 Analysis.parseSectionContents(
240 0xb0, 0x00, // 1: mov $0x0, %al
242 0x0f, 0x0b, // 4: ud2
243 0xff, 0x20, // 6: jmpq *(%rax)
244 0xeb, 0x00, // 8: jmp +0
245 0xe8, 0x45, 0xfe, 0xff, 0xff, // 10: callq [some loc]
246 0xff, 0x10, // 15: callq *(rax)
247 0x75, 0x00, // 17: jne +0
253 Analysis.canFallThrough(Analysis.getInstructionOrDie(0xDEADBEEF)));
255 Analysis.canFallThrough(Analysis.getInstructionOrDie(0xDEADBEEF + 1)));
257 Analysis.canFallThrough(Analysis.getInstructionOrDie(0xDEADBEEF + 3)));
259 Analysis.canFallThrough(Analysis.getInstructionOrDie(0xDEADBEEF + 4)));
261 Analysis.canFallThrough(Analysis.getInstructionOrDie(0xDEADBEEF + 6)));
263 Analysis.canFallThrough(Analysis.getInstructionOrDie(0xDEADBEEF + 8)));
265 Analysis.canFallThrough(Analysis.getInstructionOrDie(0xDEADBEEF + 10)));
267 Analysis.canFallThrough(Analysis.getInstructionOrDie(0xDEADBEEF + 15)));
269 Analysis.canFallThrough(Analysis.getInstructionOrDie(0xDEADBEEF + 17)));
271 Analysis.canFallThrough(Analysis.getInstructionOrDie(0xDEADBEEF + 19)));
274 TEST_F(BasicFileAnalysisTest, DefiniteNextInstructionTest) {
275 Analysis.parseSectionContents(
278 0xb0, 0x00, // 1: mov $0x0, %al
280 0x0f, 0x0b, // 4: ud2
281 0xff, 0x20, // 6: jmpq *(%rax)
282 0xeb, 0x00, // 8: jmp 10 [+0]
283 0xeb, 0x05, // 10: jmp 17 [+5]
284 0xe8, 0x00, 0x00, 0x00, 0x00, // 12: callq 17 [+0]
285 0xe8, 0x78, 0x56, 0x34, 0x12, // 17: callq 0x1234569f [+0x12345678]
286 0xe8, 0x04, 0x00, 0x00, 0x00, // 22: callq 31 [+4]
287 0xff, 0x10, // 27: callq *(rax)
288 0x75, 0x00, // 29: jne 31 [+0]
289 0x75, 0xe0, // 31: jne 1 [-32]
291 0xeb, 0xdd, // 34: jmp 1 [-35]
292 0xeb, 0xdd, // 36: jmp 3 [-35]
293 0xeb, 0xdc, // 38: jmp 4 [-36]
297 const auto *Current = Analysis.getInstruction(0xDEADBEEF);
298 const auto *Next = Analysis.getDefiniteNextInstruction(*Current);
299 EXPECT_NE(nullptr, Next);
300 EXPECT_EQ(0xDEADBEEF + 1, Next->VMAddress);
302 Current = Analysis.getInstruction(0xDEADBEEF + 1);
303 EXPECT_EQ(nullptr, Analysis.getDefiniteNextInstruction(*Current));
305 Current = Analysis.getInstruction(0xDEADBEEF + 3);
306 EXPECT_EQ(nullptr, Analysis.getDefiniteNextInstruction(*Current));
308 Current = Analysis.getInstruction(0xDEADBEEF + 4);
309 EXPECT_EQ(nullptr, Analysis.getDefiniteNextInstruction(*Current));
311 Current = Analysis.getInstruction(0xDEADBEEF + 6);
312 EXPECT_EQ(nullptr, Analysis.getDefiniteNextInstruction(*Current));
314 Current = Analysis.getInstruction(0xDEADBEEF + 8);
315 Next = Analysis.getDefiniteNextInstruction(*Current);
316 EXPECT_NE(nullptr, Next);
317 EXPECT_EQ(0xDEADBEEF + 10, Next->VMAddress);
319 Current = Analysis.getInstruction(0xDEADBEEF + 10);
320 Next = Analysis.getDefiniteNextInstruction(*Current);
321 EXPECT_NE(nullptr, Next);
322 EXPECT_EQ(0xDEADBEEF + 17, Next->VMAddress);
324 Current = Analysis.getInstruction(0xDEADBEEF + 12);
325 Next = Analysis.getDefiniteNextInstruction(*Current);
326 EXPECT_NE(nullptr, Next);
327 EXPECT_EQ(0xDEADBEEF + 17, Next->VMAddress);
329 Current = Analysis.getInstruction(0xDEADBEEF + 17);
330 // Note, definite next instruction address is out of range and should fail.
331 EXPECT_EQ(nullptr, Analysis.getDefiniteNextInstruction(*Current));
332 Next = Analysis.getDefiniteNextInstruction(*Current);
334 Current = Analysis.getInstruction(0xDEADBEEF + 22);
335 Next = Analysis.getDefiniteNextInstruction(*Current);
336 EXPECT_NE(nullptr, Next);
337 EXPECT_EQ(0xDEADBEEF + 31, Next->VMAddress);
339 Current = Analysis.getInstruction(0xDEADBEEF + 27);
340 EXPECT_EQ(nullptr, Analysis.getDefiniteNextInstruction(*Current));
341 Current = Analysis.getInstruction(0xDEADBEEF + 29);
342 EXPECT_EQ(nullptr, Analysis.getDefiniteNextInstruction(*Current));
343 Current = Analysis.getInstruction(0xDEADBEEF + 31);
344 EXPECT_EQ(nullptr, Analysis.getDefiniteNextInstruction(*Current));
345 Current = Analysis.getInstruction(0xDEADBEEF + 33);
346 EXPECT_EQ(nullptr, Analysis.getDefiniteNextInstruction(*Current));
348 Current = Analysis.getInstruction(0xDEADBEEF + 34);
349 Next = Analysis.getDefiniteNextInstruction(*Current);
350 EXPECT_NE(nullptr, Next);
351 EXPECT_EQ(0xDEADBEEF + 1, Next->VMAddress);
353 Current = Analysis.getInstruction(0xDEADBEEF + 36);
354 EXPECT_EQ(nullptr, Analysis.getDefiniteNextInstruction(*Current));
356 Current = Analysis.getInstruction(0xDEADBEEF + 38);
357 Next = Analysis.getDefiniteNextInstruction(*Current);
358 EXPECT_NE(nullptr, Next);
359 EXPECT_EQ(0xDEADBEEF + 4, Next->VMAddress);
362 TEST_F(BasicFileAnalysisTest, ControlFlowXRefsTest) {
363 Analysis.parseSectionContents(
366 0xb0, 0x00, // 1: mov $0x0, %al
368 0x0f, 0x0b, // 4: ud2
369 0xff, 0x20, // 6: jmpq *(%rax)
370 0xeb, 0x00, // 8: jmp 10 [+0]
371 0xeb, 0x05, // 10: jmp 17 [+5]
372 0xe8, 0x00, 0x00, 0x00, 0x00, // 12: callq 17 [+0]
373 0xe8, 0x78, 0x56, 0x34, 0x12, // 17: callq 0x1234569f [+0x12345678]
374 0xe8, 0x04, 0x00, 0x00, 0x00, // 22: callq 31 [+4]
375 0xff, 0x10, // 27: callq *(rax)
376 0x75, 0x00, // 29: jne 31 [+0]
377 0x75, 0xe0, // 31: jne 1 [-32]
379 0xeb, 0xdd, // 34: jmp 1 [-35]
380 0xeb, 0xdd, // 36: jmp 3 [-35]
381 0xeb, 0xdc, // 38: jmp 4 [-36]
384 const auto *InstrMetaPtr = &Analysis.getInstructionOrDie(0xDEADBEEF);
385 std::set<const Instr *> XRefs =
386 Analysis.getDirectControlFlowXRefs(*InstrMetaPtr);
387 EXPECT_TRUE(XRefs.empty());
389 InstrMetaPtr = &Analysis.getInstructionOrDie(0xDEADBEEF + 1);
390 XRefs = Analysis.getDirectControlFlowXRefs(*InstrMetaPtr);
391 EXPECT_THAT(XRefs, UnorderedElementsAre(
392 Field(&Instr::VMAddress, Eq(0xDEADBEEF)),
393 Field(&Instr::VMAddress, Eq(0xDEADBEEF + 31)),
394 Field(&Instr::VMAddress, Eq(0xDEADBEEF + 34))));
396 InstrMetaPtr = &Analysis.getInstructionOrDie(0xDEADBEEF + 3);
397 XRefs = Analysis.getDirectControlFlowXRefs(*InstrMetaPtr);
398 EXPECT_THAT(XRefs, UnorderedElementsAre(
399 Field(&Instr::VMAddress, Eq(0xDEADBEEF + 1)),
400 Field(&Instr::VMAddress, Eq(0xDEADBEEF + 36))));
402 InstrMetaPtr = &Analysis.getInstructionOrDie(0xDEADBEEF + 4);
403 XRefs = Analysis.getDirectControlFlowXRefs(*InstrMetaPtr);
404 EXPECT_THAT(XRefs, UnorderedElementsAre(
405 Field(&Instr::VMAddress, Eq(0xDEADBEEF + 38))));
407 InstrMetaPtr = &Analysis.getInstructionOrDie(0xDEADBEEF + 6);
408 EXPECT_TRUE(Analysis.getDirectControlFlowXRefs(*InstrMetaPtr).empty());
410 InstrMetaPtr = &Analysis.getInstructionOrDie(0xDEADBEEF + 8);
411 XRefs = Analysis.getDirectControlFlowXRefs(*InstrMetaPtr);
412 EXPECT_TRUE(Analysis.getDirectControlFlowXRefs(*InstrMetaPtr).empty());
414 InstrMetaPtr = &Analysis.getInstructionOrDie(0xDEADBEEF + 10);
415 XRefs = Analysis.getDirectControlFlowXRefs(*InstrMetaPtr);
416 EXPECT_THAT(XRefs, UnorderedElementsAre(
417 Field(&Instr::VMAddress, Eq(0xDEADBEEF + 8))));
419 InstrMetaPtr = &Analysis.getInstructionOrDie(0xDEADBEEF + 12);
420 XRefs = Analysis.getDirectControlFlowXRefs(*InstrMetaPtr);
421 EXPECT_TRUE(Analysis.getDirectControlFlowXRefs(*InstrMetaPtr).empty());
423 InstrMetaPtr = &Analysis.getInstructionOrDie(0xDEADBEEF + 17);
424 XRefs = Analysis.getDirectControlFlowXRefs(*InstrMetaPtr);
425 EXPECT_THAT(XRefs, UnorderedElementsAre(
426 Field(&Instr::VMAddress, Eq(0xDEADBEEF + 10)),
427 Field(&Instr::VMAddress, Eq(0xDEADBEEF + 12))));
429 InstrMetaPtr = &Analysis.getInstructionOrDie(0xDEADBEEF + 22);
430 XRefs = Analysis.getDirectControlFlowXRefs(*InstrMetaPtr);
431 EXPECT_TRUE(Analysis.getDirectControlFlowXRefs(*InstrMetaPtr).empty());
433 InstrMetaPtr = &Analysis.getInstructionOrDie(0xDEADBEEF + 27);
434 XRefs = Analysis.getDirectControlFlowXRefs(*InstrMetaPtr);
435 EXPECT_TRUE(Analysis.getDirectControlFlowXRefs(*InstrMetaPtr).empty());
437 InstrMetaPtr = &Analysis.getInstructionOrDie(0xDEADBEEF + 29);
438 XRefs = Analysis.getDirectControlFlowXRefs(*InstrMetaPtr);
439 EXPECT_TRUE(Analysis.getDirectControlFlowXRefs(*InstrMetaPtr).empty());
441 InstrMetaPtr = &Analysis.getInstructionOrDie(0xDEADBEEF + 31);
442 XRefs = Analysis.getDirectControlFlowXRefs(*InstrMetaPtr);
443 EXPECT_THAT(XRefs, UnorderedElementsAre(
444 Field(&Instr::VMAddress, Eq(0xDEADBEEF + 22)),
445 Field(&Instr::VMAddress, Eq(0xDEADBEEF + 29))));
447 InstrMetaPtr = &Analysis.getInstructionOrDie(0xDEADBEEF + 33);
448 XRefs = Analysis.getDirectControlFlowXRefs(*InstrMetaPtr);
449 EXPECT_THAT(XRefs, UnorderedElementsAre(
450 Field(&Instr::VMAddress, Eq(0xDEADBEEF + 31))));
452 InstrMetaPtr = &Analysis.getInstructionOrDie(0xDEADBEEF + 34);
453 XRefs = Analysis.getDirectControlFlowXRefs(*InstrMetaPtr);
454 EXPECT_TRUE(Analysis.getDirectControlFlowXRefs(*InstrMetaPtr).empty());
456 InstrMetaPtr = &Analysis.getInstructionOrDie(0xDEADBEEF + 36);
457 XRefs = Analysis.getDirectControlFlowXRefs(*InstrMetaPtr);
458 EXPECT_TRUE(Analysis.getDirectControlFlowXRefs(*InstrMetaPtr).empty());
460 InstrMetaPtr = &Analysis.getInstructionOrDie(0xDEADBEEF + 38);
461 XRefs = Analysis.getDirectControlFlowXRefs(*InstrMetaPtr);
462 EXPECT_TRUE(Analysis.getDirectControlFlowXRefs(*InstrMetaPtr).empty());
465 } // anonymous namespace
466 } // end namespace cfi_verify
467 } // end namespace llvm
469 int main(int argc, char **argv) {
470 ::testing::InitGoogleTest(&argc, argv);
471 llvm::cl::ParseCommandLineOptions(argc, argv);
473 llvm::InitializeAllTargetInfos();
474 llvm::InitializeAllTargetMCs();
475 llvm::InitializeAllAsmParsers();
476 llvm::InitializeAllDisassemblers();
478 return RUN_ALL_TESTS();