-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathGenerateAutomataTruePass.cpp
More file actions
624 lines (551 loc) · 21 KB
/
Copy pathGenerateAutomataTruePass.cpp
File metadata and controls
624 lines (551 loc) · 21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
/**
* Copyright (C) 2014 - 2020 Map2Check tool
* This file is part of the Map2Check tool, and is made available under
* the terms of the GNU General Public License version 2.
*
* LLVM -> NCSA
*
* SPDX-License-Identifier: (GPL-2.0 AND NCSA)
**/
#include "GenerateAutomataTruePass.hpp"
#include <fstream>
#include <iostream>
#include <memory>
#include <sstream>
#include <stdexcept>
#include <string>
#include <vector>
#include <llvm/Passes/PassBuilder.h>
#include <llvm/Passes/PassPlugin.h>
using llvm::CallInst;
using llvm::cast;
using llvm::dyn_cast;
using llvm::isa;
using llvm::LoadInst;
// TerminatorInst removed in LLVM 10+ — use Instruction directly
using std::ofstream;
namespace {
inline Instruction* BBIteratorToInst(BasicBlock::iterator i) {
Instruction* pointer = reinterpret_cast<Instruction*>(&*i);
return pointer;
}
} // namespace
// TODO(hbgit): Skip assume generated by our tool. Keep assumes come from the
// analyzed source code?
PreservedAnalyses GenerateAutomataTruePass::run(Function& F,
llvm::FunctionAnalysisManager& AM) {
this->Ctx = &F.getContext();
this->currentFunction = &F;
this->st_currentFunctionName = this->currentFunction->getName();
int countBB = 1;
// for (Function::iterator B = F.begin(), e = F.end(); B != e; ++B)
for (auto& B : F) {
this->hasCallOnBasicBlock(B, this->Ctx);
this->runOnBasicBlock(B, this->Ctx);
this->printStateData();
countBB++;
}
return PreservedAnalyses::none();
}
namespace {
inline void replaceAll(std::string& str, const std::string& from, const std::string& to) {
std::string::size_type pos = 0;
while ((pos = str.find(from, pos)) != std::string::npos) {
str.replace(pos, from.length(), to);
pos += to.length();
}
}
} // namespace
// Replace text code not allowed in XML
std::string GenerateAutomataTruePass::replaceCodeByXml(
std::string sourceCodeTxt) {
replaceAll(sourceCodeTxt, "&", "&");
replaceAll(sourceCodeTxt, "<", "<");
replaceAll(sourceCodeTxt, ">", ">");
replaceAll(sourceCodeTxt, "<=", "<= ");
replaceAll(sourceCodeTxt, ">=", ">= ");
return sourceCodeTxt;
}
void GenerateAutomataTruePass::hasCallOnBasicBlock(BasicBlock& B,
LLVMContext* Ctx) {
// if(this->currentFunction->getName() == "main")
//{
for (BasicBlock::iterator i = B.begin(), ie = B.end(); i != ie; ++i) {
// for(auto& I:B)
//{
if (auto* cI = dyn_cast<CallInst>(BBIteratorToInst(i))) {
// avoid bug if call pointer functions
if (!cI->getCalledOperand()->getName().empty()) {
Value* v = cI->getCalledOperand();
Function* calleeFunction = dyn_cast<Function>(v->stripPointerCasts());
if (calleeFunction->getName() != "__VERIFIER_assume" &&
calleeFunction->getName() != "__VERIFIER_nondet_int" &&
calleeFunction->getName() != "__VERIFIER_nondet_char" &&
calleeFunction->getName() != "__VERIFIER_nondet_pointer" &&
calleeFunction->getName() != "__VERIFIER_nondet_long" &&
calleeFunction->getName() != "__VERIFIER_nondet_ushort" &&
calleeFunction->getName() != "map2check_assume" &&
calleeFunction->getName() != "malloc" &&
calleeFunction->getName() != "calloc" &&
calleeFunction->getName() != "realloc" &&
calleeFunction->getName() != "free") {
// BasicBlock::iterator iI= &;
// i->dump();
DebugInfo debugInfoFi(this->Ctx, BBIteratorToInst(i));
this->st_numLineBeginBB = debugInfoFi.getLineNumberInt();
this->st_isControl = false;
this->st_isEntryPoint = true;
this->countEntryPoint++;
// this->st_sourceCodeLine =
// this->sourceCodeHelper->getLine(debugInfoFi.getLineNumberInt());
this->st_sourceCodeLine = this->replaceCodeByXml(
this->sourceCodeHelper->getLine(debugInfoFi.getLineNumberInt()));
this->st_startline = debugInfoFi.getLineNumberInt();
this->printStateData();
}
}
}
}
//}
}
void GenerateAutomataTruePass::printStateData() {
if (this->enableDataBlk) {
ofstream filest;
filest.open("automata_list_log.st", std::ios_base::app);
filest << this->st_currentFunctionName << "@";
filest << this->st_numLineBeginBB << "@";
filest << this->st_startline << "@";
filest << this->st_sourceCodeLine << "@";
if (this->st_isControl && this->numLineControlSt == this->st_startline) {
filest << this->st_controlCode << "@1@";
filest << this->st_numLineGoControl_1true << "@";
filest << this->st_numLineGoControl_2false << "@";
} else {
filest << "NONE@0@NONE@NONE@";
}
filest << this->st_isEntryPoint << "@";
filest << this->st_isErrorLocation << "\n";
filest.close();
}
// To write the automata the flow should be using the function name and its
// call
}
void GenerateAutomataTruePass::runOnBasicBlock(BasicBlock& B,
LLVMContext* Ctx) {
this->actualSizeBB = B.size();
this->firstBlockInst = B.begin();
this->st_lastBlockInst =
--B.end(); // -- is necessary to avoid the pointer to the next block
this->enableDataBlk = false;
bool isCond = false;
this->numLineControlSt = 0;
// Getting data from BB begin
DebugInfo debugInfoFi(this->Ctx, BBIteratorToInst(this->firstBlockInst));
this->st_numLineBeginBB = debugInfoFi.getLineNumberInt();
// Identifying asserts on analayzed code
this->identifyAssertLoc(B);
// if(!this->checkBBHasLError(B))
//{
//}
this->checkBBHasLError(B);
// Create a method to get info from branches in the block for condition-true
// and false
isCond = this->isBranchCond(B);
this->st_isControl = isCond;
if (B.size() > 1) {
if (auto* tI = dyn_cast<Instruction>(&*this->st_lastBlockInst)) {
if (std::string(tI->getOpcodeName()) == "br") {
--this->st_lastBlockInst;
this->checkAndSkipAssume();
// DebugInfo debugInfoLa(this->Ctx,
// (Instruction*)this->st_lastBlockInst); this->st_startline =
// debugInfoLa.getLineNumberInt(); this->st_sourceCodeLine =
// this->sourceCodeHelper->getLine(debugInfoLa.getLineNumberInt());
} else {
DebugInfo debugInfoLa(this->Ctx,
BBIteratorToInst(this->st_lastBlockInst));
if (this->sourceCodeHelper->getLine(debugInfoLa.getLineNumberInt())
.empty()) {
// int numline = debugInfoLa.getLineNumberInt() - 1;
// this->st_startline = numline;
// this->st_sourceCodeLine = this->sourceCodeHelper->getLine(numline);
this->skipEmptyLine();
} else {
// this->st_startline = debugInfoLa.getLineNumberInt();
// this->st_sourceCodeLine =
// this->sourceCodeHelper->getLine(debugInfoLa.getLineNumberInt());
this->checkAndSkipAssume();
}
}
}
this->enableDataBlk = true;
} else {
// In case this unique instruction be a "br" then we remove this basic block
if (auto* tI = dyn_cast<Instruction>(&*this->st_lastBlockInst)) {
if (std::string(tI->getOpcodeName()) != "br") {
this->st_lastBlockInst = this->firstBlockInst;
// DebugInfo debugInfoLa(this->Ctx,
// (Instruction*)this->st_lastBlockInst); this->st_startline =
// debugInfoLa.getLineNumberInt();
// this->st_sourceCodeLine =
// this->sourceCodeHelper->getLine(debugInfoLa.getLineNumberInt());
this->checkAndSkipAssume();
this->enableDataBlk = true;
}
}
}
if (this->enableDataBlk) {
// this->visitInstruction(i);
if (this->currentFunction->getName() == "main") {
if (this->countEntryPoint == 1 && this->st_isEntryPoint == false) {
this->st_isEntryPoint = true;
this->countEntryPoint++;
} else {
this->st_isEntryPoint = false;
}
}
}
}
bool GenerateAutomataTruePass::checkInstBbIsAssume(BasicBlock::iterator& iT) {
if (auto* cI = dyn_cast<CallInst>(BBIteratorToInst(iT))) {
if (!cI->getCalledOperand()->getName().empty()) {
Value* v = cI->getCalledOperand();
Function* calleeFunction = dyn_cast<Function>(v->stripPointerCasts());
if (calleeFunction->getName() == "__VERIFIER_assume" ||
calleeFunction->getName() == "map2check_assume") {
return true;
} else {
return false;
}
}
}
return false;
}
// Checking if the instruction is an ASSUME to skip
void GenerateAutomataTruePass::checkAndSkipAssume() {
DebugInfo debugInfoLa(this->Ctx, BBIteratorToInst(this->st_lastBlockInst));
this->numLineBlk_ori = debugInfoLa.getLineNumberInt();
bool flagAssume = false;
if (this->checkInstBbIsAssume(this->st_lastBlockInst)) {
flagAssume = true;
} else {
this->st_startline = this->numLineBlk_ori;
// this->st_sourceCodeLine =
// this->sourceCodeHelper->getLine(this->numLineBlk_ori);
this->st_sourceCodeLine = this->replaceCodeByXml(
this->sourceCodeHelper->getLine(this->numLineBlk_ori));
}
while (flagAssume) {
--this->st_lastBlockInst;
DebugInfo debugInfoAa(this->Ctx, BBIteratorToInst(this->st_lastBlockInst));
this->numLineBlk_AA = debugInfoAa.getLineNumberInt();
if (this->numLineBlk_AA == this->numLineBlk_ori) {
flagAssume = true;
} else {
flagAssume = false;
if (this->sourceCodeHelper->getLine(this->numLineBlk_AA).empty()) {
this->skipEmptyLine();
} else {
this->st_startline = this->numLineBlk_AA;
// this->st_sourceCodeLine =
// this->sourceCodeHelper->getLine(this->numLineBlk_AA);
this->st_sourceCodeLine = this->replaceCodeByXml(
this->sourceCodeHelper->getLine(this->numLineBlk_AA));
}
}
}
}
void GenerateAutomataTruePass::skipEmptyLine() {
bool flagEmpty = true;
int countInstBlk = 1;
bool lastInst = false;
while (flagEmpty) {
// this->st_lastBlockInst->dump();
// errs() << this->actualSizeBB << "\n";
if (countInstBlk < this->actualSizeBB) {
--this->st_lastBlockInst;
countInstBlk++;
} else {
lastInst = true;
}
DebugInfo debugInfoAaEmptyW(this->Ctx,
BBIteratorToInst(this->st_lastBlockInst));
if (this->sourceCodeHelper->getLine(debugInfoAaEmptyW.getLineNumberInt())
.empty()) {
if (!lastInst) {
flagEmpty = true;
} else {
flagEmpty = false;
this->st_startline = debugInfoAaEmptyW.getLineNumberInt();
// errs() << this->st_startline << "\n";
// this->st_sourceCodeLine =
// this->sourceCodeHelper->getLine(debugInfoAaEmptyW.getLineNumberInt());
this->st_sourceCodeLine =
this->replaceCodeByXml(this->sourceCodeHelper->getLine(
debugInfoAaEmptyW.getLineNumberInt()));
}
} else {
flagEmpty = false;
this->st_startline = debugInfoAaEmptyW.getLineNumberInt();
// this->st_sourceCodeLine =
// this->sourceCodeHelper->getLine(debugInfoAaEmptyW.getLineNumberInt());
this->st_sourceCodeLine =
this->replaceCodeByXml(this->sourceCodeHelper->getLine(
debugInfoAaEmptyW.getLineNumberInt()));
}
}
}
void GenerateAutomataTruePass::identifyAssertLoc(BasicBlock& B) {
for (auto& I : B) {
if (auto* cI = dyn_cast<CallInst>(&I)) {
if (!cI->getCalledOperand()->getName().empty()) {
Value* v = cI->getCalledOperand();
Function* calleeFunction = dyn_cast<Function>(v->stripPointerCasts());
// errs() << calleeFunction->getName() << "\n";
if (calleeFunction->getName() == "__VERIFIER_assert") {
DebugInfo debugInfoCi(this->Ctx, cI);
this->assertListLoc.push_back(debugInfoCi.getLineNumberInt());
}
}
}
}
}
BasicBlock::iterator& GenerateAutomataTruePass::skipEmptyLineIt(
BasicBlock::iterator& iT) {
bool flagEmpty = true;
int countInst = 1;
while (flagEmpty) {
DebugInfo debugInfoAaEmptyW(this->Ctx, BBIteratorToInst(iT));
bool skip = false;
// errs() <<
// this->sourceCodeHelper->getLine(debugInfoAaEmptyW.getLineNumberInt()) <<
// "<<<<<<<<<<<< \n";
if (this->sourceCodeHelper->getLine(debugInfoAaEmptyW.getLineNumberInt())
.empty() ||
this->sourceCodeHelper->getLine(debugInfoAaEmptyW.getLineNumberInt()) ==
"}") {
skip = true;
}
if (std::string(iT->getOpcodeName()) == "br" || skip) {
// errs() << "HERE \n";
// errs() <<countInst << "<" << this->actualSizeBB << "\n";
if (countInst < this->skipEmptyLineItSize) {
--iT;
countInst++;
flagEmpty = true;
} else {
flagEmpty = false;
}
} else {
flagEmpty = false;
}
}
return iT;
}
// Identify if the block has a branch and define the condition to true and false
bool GenerateAutomataTruePass::isBranchCond(BasicBlock& B) {
// errs() << bbName << "\n";
std::vector<int>::const_iterator iT;
bool retResult = false;
for (auto& I : B) {
if (auto* bI = dyn_cast<ICmpInst>(&I)) {
// bI->dump();
// errs() << this->convertLLPredicateToXmlText(I) << "\n";
//
DebugInfo debugInfoBi(this->Ctx, bI);
// errs() << debugInfoBi.getLineNumberInt() << "\n";
// Skiping when the Branch was an assertion
iT = std::find(this->assertListLoc.begin(), this->assertListLoc.end(),
debugInfoBi.getLineNumberInt());
if (!(iT != this->assertListLoc.end())) {
// errs() << "control : " << this->convertLLPredicateToXmlText(I) <<
// "\n";
this->st_controlCode = this->convertLLPredicateToXmlText(I);
this->numLineControlSt = debugInfoBi.getLineNumberInt();
// getting true and false linenum from bb
retResult = true;
}
}
if (auto* tI = dyn_cast<Instruction>(&I)) {
if (std::string(tI->getOpcodeName()) == "br") {
// tI->dump();
if (tI->getNumSuccessors() > 1) {
// TRUE cond
this->skipEmptyLineItSize = tI->getSuccessor(0)->size();
BasicBlock::iterator trueCond = --tI->getSuccessor(0)->end();
if (std::string(trueCond->getOpcodeName()) == "br" &&
tI->getSuccessor(0)->size() == 1) {
trueCond = --tI->getSuccessor(0)->getSingleSuccessor()->end();
}
if (std::string(trueCond->getOpcodeName()) == "br" ||
std::string(trueCond->getOpcodeName()) == "ret") {
trueCond = this->skipEmptyLineIt(trueCond);
}
// errs() << "TRUE \n";
// trueCond->dump();
DebugInfo debugInfoT(this->Ctx, BBIteratorToInst(trueCond));
this->st_numLineGoControl_1true = debugInfoT.getLineNumberInt();
// FALSE cond
// tI->getSuccessor(1)->dump();
// tI->getSuccessor(1)->begin()->dump();
BasicBlock::iterator falseCond;
this->skipEmptyLineItSize = tI->getSuccessor(1)->size();
if (this->actualSizeBB > 1) {
falseCond = --tI->getSuccessor(1)->end();
} else {
falseCond = tI->getSuccessor(1)->begin();
}
// falseCond->dump();
if (std::string(falseCond->getOpcodeName()) == "br" &&
tI->getSuccessor(1)->size() == 1) {
falseCond = --tI->getSuccessor(1)->getSingleSuccessor()->end();
}
if (std::string(falseCond->getOpcodeName()) == "br" ||
std::string(falseCond->getOpcodeName()) == "ret") {
falseCond = this->skipEmptyLineIt(falseCond);
}
// falseCond->dump();
DebugInfo debugInfoF(this->Ctx, BBIteratorToInst(falseCond));
this->st_numLineGoControl_2false = debugInfoF.getLineNumberInt();
// errs() << this->st_numLineGoControl_2false << " --- \n";
}
}
}
}
if (retResult) {
return true;
} else {
return false;
}
}
std::string GenerateAutomataTruePass::convertLLPredicateToXmlText(
Instruction& I) {
std::string lvaluep;
std::string rvaluep;
std::string predicateInXml;
std::string fullExpPredicateInXml;
std::ostringstream osstrtmp;
if (auto* bI = dyn_cast<ICmpInst>(&I)) {
// bI->dump();
// errs() << bI->getSignedPredicate() << "\n";
// errs() << this->getPredicateSymOnXmlText(*bI) << "\n";
predicateInXml = this->getPredicateSymOnXmlText(*bI);
// errs() << *bI->getOperand(0) << "\n";
// errs() << bI->getOperand(0)->getValueName() << "\n";
// Getting left value from predicate
if (isa<LoadInst>(bI->getOperand(0))) {
LoadInst* LD100 = cast<LoadInst>(bI->getOperand(0));
Value* C100 = LD100->getPointerOperand();
lvaluep = C100->getName().str();
// errs() << "LVALUEP: " << lvaluep << "\n";
} else if (ConstantInt* CI = dyn_cast<ConstantInt>(bI->getOperand(0))) {
if (CI->getBitWidth() <=
32) { // Of course, you can also change it to <= 64 if constIntValue
// is a 64-bit integer, etc.
// constIntValue = CI->getSExtValue();
osstrtmp << CI->getSExtValue();
rvaluep = osstrtmp.str();
// errs() << "LVALUEP:" << lvaluep << "\n";
}
}
// Instruction tmpI = (Instruction) &*bI->getOperand(0);
// errs() << *bI->getOperand(1) << "\n";
// Getting right value from predicate
if (isa<LoadInst>(bI->getOperand(1))) {
LoadInst* LD101 = cast<LoadInst>(bI->getOperand(1));
Value* C101 = LD101->getPointerOperand(); // HERE COMPILATION ERROR
rvaluep = C101->getName().str();
// errs() << "RVALUEP:" << rvaluep << "\n";
} else if (ConstantInt* CI = dyn_cast<ConstantInt>(bI->getOperand(1))) {
// errs() << bI->getOperand(1)->getName().str() << "\n";
// Of course, you can also change it to <= 64 if constIntValue
// is a 64-bit integer, etc.
// constIntValue = CI->getSExtValue();
if (CI->getBitWidth() <= 32) {
osstrtmp << CI->getSExtValue();
rvaluep = osstrtmp.str();
// errs() << "RVALUEP:" << rvaluep << "\n";
}
}
//}
// Generate full predicate expression
// errs() << lvaluep.empty() << "==\n";
// errs() << rvaluep.empty() << "==\n";
// errs() << "[" + lvaluep + " " + predicateInXml + " " + rvaluep + "]" <<
// "\n";
if (this->isPredicateNe && lvaluep.empty()) {
fullExpPredicateInXml = "[ !" + rvaluep + "]";
} else if (this->isPredicateNe && rvaluep.empty()) {
fullExpPredicateInXml = "[ !" + lvaluep + "]";
} else {
fullExpPredicateInXml =
"[" + lvaluep + " " + predicateInXml + " " + rvaluep + "]";
}
// errs() << fullExpPredicateInXml << "\n";
return fullExpPredicateInXml;
}
return "[]";
}
std::string GenerateAutomataTruePass::getPredicateSymOnXmlText(
ICmpInst& icmpInst) {
std::string predicateText = "";
this->isPredicateNe = false;
ICmpInst::Predicate pr = icmpInst.getSignedPredicate();
if (pr == ICmpInst::ICMP_EQ) {
predicateText = "==";
} else if (pr == ICmpInst::ICMP_NE) {
predicateText = "!=";
this->isPredicateNe = true;
} else if (pr == ICmpInst::ICMP_SGT) {
predicateText = ">";
} else if (pr == ICmpInst::ICMP_SGE) {
predicateText = ">=";
} else if (pr == ICmpInst::ICMP_SLT) {
predicateText = "<";
} else if (pr == ICmpInst::ICMP_SLE) {
predicateText = "<=";
}
/**switch(pr){
case ICmpInst::ICMP_SGT: predicateText=">"; break;
case ICmpInst::ICMP_SLT: predicateText="<"; break;
case ICmpInst::ICMP_SGE: predicateText="≥"; break;
case ICmpInst::ICMP_SLE: predicateText="≤"; break;
}**/
return predicateText;
}
// To identify a block with a error location by __VERIFIER_error call function
bool GenerateAutomataTruePass::checkBBHasLError(BasicBlock& nowB) {
this->st_isErrorLocation = 0;
for (auto& I : nowB) {
if (CallInst* callInst = dyn_cast<CallInst>(&I)) {
if (!callInst->getCalledOperand()->getName().empty()) {
// errs() << callInst->getCalledFunction()->getName() << "\n";
Value* v = callInst->getCalledOperand();
Function* calleeFunction = dyn_cast<Function>(v->stripPointerCasts());
if (calleeFunction->getName() == "__VERIFIER_error") {
this->st_isErrorLocation = 1;
return true;
}
}
}
}
// std::cout << i.begin << "\n";
// std::cout << i->getOpcodeName(i->getOpcode()) << std::endl;
return false;
}
// --- New Pass Manager plugin registration ---
extern "C" LLVM_ATTRIBUTE_WEAK ::llvm::PassPluginLibraryInfo
llvmGetPassPluginInfo() {
return {LLVM_PLUGIN_API_VERSION, "GenerateAutomataTruePass", LLVM_VERSION_STRING,
[](llvm::PassBuilder& PB) {
PB.registerPipelineParsingCallback(
[](llvm::StringRef Name, llvm::FunctionPassManager& FPM,
llvm::ArrayRef<llvm::PassBuilder::PipelineElement>) {
if (Name == "generate-automata-true") {
FPM.addPass(GenerateAutomataTruePass());
return true;
}
return false;
});
}};
}