clang 22.0.0git
ThreadSafetyCommon.h
Go to the documentation of this file.
1//===- ThreadSafetyCommon.h -------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// Parts of thread safety analysis that are not specific to thread safety
10// itself have been factored into classes here, where they can be potentially
11// used by other analyses. Currently these include:
12//
13// * Generalize clang CFG visitors.
14// * Conversion of the clang CFG to SSA form.
15// * Translation of clang Exprs to TIL SExprs
16//
17// UNDER CONSTRUCTION. USE AT YOUR OWN RISK.
18//
19//===----------------------------------------------------------------------===//
20
21#ifndef LLVM_CLANG_ANALYSIS_ANALYSES_THREADSAFETYCOMMON_H
22#define LLVM_CLANG_ANALYSIS_ANALYSES_THREADSAFETYCOMMON_H
23
24#include "clang/AST/Decl.h"
25#include "clang/AST/Type.h"
31#include "clang/Analysis/CFG.h"
32#include "clang/Basic/LLVM.h"
33#include "llvm/ADT/DenseMap.h"
34#include "llvm/ADT/PointerIntPair.h"
35#include "llvm/ADT/PointerUnion.h"
36#include "llvm/ADT/SmallVector.h"
37#include "llvm/Support/Casting.h"
38#include <functional>
39#include <sstream>
40#include <string>
41#include <utility>
42#include <vector>
43
44namespace clang {
45
48class BinaryOperator;
49class CallExpr;
50class CastExpr;
54class CXXThisExpr;
55class DeclRefExpr;
56class DeclStmt;
57class Expr;
58class MemberExpr;
59class Stmt;
60class UnaryOperator;
61
62namespace threadSafety {
63
64// Various helper functions on til::SExpr
65namespace sx {
66
67inline bool equals(const til::SExpr *E1, const til::SExpr *E2) {
69}
70
71inline bool matches(const til::SExpr *E1, const til::SExpr *E2) {
72 // We treat a top-level wildcard as the "univsersal" lock.
73 // It matches everything for the purpose of checking locks, but not
74 // for unlocking them.
75 if (isa<til::Wildcard>(E1))
76 return isa<til::Wildcard>(E2);
77 if (isa<til::Wildcard>(E2))
78 return isa<til::Wildcard>(E1);
79
81}
82
83inline bool partiallyMatches(const til::SExpr *E1, const til::SExpr *E2) {
84 const auto *PE1 = dyn_cast_or_null<til::Project>(E1);
85 if (!PE1)
86 return false;
87 const auto *PE2 = dyn_cast_or_null<til::Project>(E2);
88 if (!PE2)
89 return false;
90 return PE1->clangDecl() == PE2->clangDecl();
91}
92
93inline std::string toString(const til::SExpr *E) {
94 std::stringstream ss;
96 return ss.str();
97}
98
99} // namespace sx
100
101// This class defines the interface of a clang CFG Visitor.
102// CFGWalker will invoke the following methods.
103// Note that methods are not virtual; the visitor is templatized.
105 // Enter the CFG for Decl D, and perform any initial setup operations.
106 void enterCFG(CFG *Cfg, const NamedDecl *D, const CFGBlock *First) {}
107
108 // Enter a CFGBlock.
109 void enterCFGBlock(const CFGBlock *B) {}
110
111 // Returns true if this visitor implements handlePredecessor
112 bool visitPredecessors() { return true; }
113
114 // Process a predecessor edge.
115 void handlePredecessor(const CFGBlock *Pred) {}
116
117 // Process a successor back edge to a previously visited block.
118 void handlePredecessorBackEdge(const CFGBlock *Pred) {}
119
120 // Called just before processing statements.
121 void enterCFGBlockBody(const CFGBlock *B) {}
122
123 // Process an ordinary statement.
124 void handleStatement(const Stmt *S) {}
125
126 // Process a destructor call
127 void handleDestructorCall(const VarDecl *VD, const CXXDestructorDecl *DD) {}
128
129 // Called after all statements have been handled.
130 void exitCFGBlockBody(const CFGBlock *B) {}
131
132 // Return true
133 bool visitSuccessors() { return true; }
134
135 // Process a successor edge.
136 void handleSuccessor(const CFGBlock *Succ) {}
137
138 // Process a successor back edge to a previously visited block.
139 void handleSuccessorBackEdge(const CFGBlock *Succ) {}
140
141 // Leave a CFGBlock.
142 void exitCFGBlock(const CFGBlock *B) {}
143
144 // Leave the CFG, and perform any final cleanup operations.
145 void exitCFG(const CFGBlock *Last) {}
146};
147
148// Walks the clang CFG, and invokes methods on a given CFGVisitor.
150public:
151 CFGWalker() = default;
152
153 // Initialize the CFGWalker. This setup only needs to be done once, even
154 // if there are multiple passes over the CFG.
156 ACtx = &AC;
157 CFGraph = AC.getCFG();
158 if (!CFGraph)
159 return false;
160
161 // Ignore anonymous functions.
162 if (!isa_and_nonnull<NamedDecl>(AC.getDecl()))
163 return false;
164
165 SortedGraph = AC.getAnalysis<PostOrderCFGView>();
166 if (!SortedGraph)
167 return false;
168
169 return true;
170 }
171
172 // Traverse the CFG, calling methods on V as appropriate.
173 template <class Visitor>
174 void walk(Visitor &V) {
175 PostOrderCFGView::CFGBlockSet VisitedBlocks(CFGraph);
176
177 V.enterCFG(CFGraph, getDecl(), &CFGraph->getEntry());
178
179 for (const auto *CurrBlock : *SortedGraph) {
180 VisitedBlocks.insert(CurrBlock);
181
182 V.enterCFGBlock(CurrBlock);
183
184 // Process predecessors, handling back edges last
185 if (V.visitPredecessors()) {
187 // Process successors
188 for (CFGBlock::const_pred_iterator SI = CurrBlock->pred_begin(),
189 SE = CurrBlock->pred_end();
190 SI != SE; ++SI) {
191 if (*SI == nullptr)
192 continue;
193
194 if (!VisitedBlocks.alreadySet(*SI)) {
195 BackEdges.push_back(*SI);
196 continue;
197 }
198 V.handlePredecessor(*SI);
199 }
200
201 for (auto *Blk : BackEdges)
202 V.handlePredecessorBackEdge(Blk);
203 }
204
205 V.enterCFGBlockBody(CurrBlock);
206
207 // Process statements
208 for (const auto &BI : *CurrBlock) {
209 switch (BI.getKind()) {
211 V.handleStatement(BI.castAs<CFGStmt>().getStmt());
212 break;
213
216 V.handleDestructorCall(AD.getVarDecl(),
217 AD.getDestructorDecl(ACtx->getASTContext()));
218 break;
219 }
220 default:
221 break;
222 }
223 }
224
225 V.exitCFGBlockBody(CurrBlock);
226
227 // Process successors, handling back edges first.
228 if (V.visitSuccessors()) {
229 SmallVector<CFGBlock*, 8> ForwardEdges;
230
231 // Process successors
232 for (CFGBlock::const_succ_iterator SI = CurrBlock->succ_begin(),
233 SE = CurrBlock->succ_end();
234 SI != SE; ++SI) {
235 if (*SI == nullptr)
236 continue;
237
238 if (!VisitedBlocks.alreadySet(*SI)) {
239 ForwardEdges.push_back(*SI);
240 continue;
241 }
242 V.handleSuccessorBackEdge(*SI);
243 }
244
245 for (auto *Blk : ForwardEdges)
246 V.handleSuccessor(Blk);
247 }
248
249 V.exitCFGBlock(CurrBlock);
250 }
251 V.exitCFG(&CFGraph->getExit());
252 }
253
254 const CFG *getGraph() const { return CFGraph; }
255 CFG *getGraph() { return CFGraph; }
256
257 const NamedDecl *getDecl() const {
258 return dyn_cast<NamedDecl>(ACtx->getDecl());
259 }
260
261 const PostOrderCFGView *getSortedGraph() const { return SortedGraph; }
262
263private:
264 CFG *CFGraph = nullptr;
265 AnalysisDeclContext *ACtx = nullptr;
266 PostOrderCFGView *SortedGraph = nullptr;
267};
268
269// TODO: move this back into ThreadSafety.cpp
270// This is specific to thread safety. It is here because
271// translateAttrExpr needs it, but that should be moved too.
273private:
274 static constexpr unsigned FlagNegative = 1u << 0;
275 static constexpr unsigned FlagReentrant = 1u << 1;
276
277 /// The capability expression and flags.
278 llvm::PointerIntPair<const til::SExpr *, 2, unsigned> CapExpr;
279
280 /// The kind of capability as specified by @ref CapabilityAttr::getName.
281 StringRef CapKind;
282
283public:
284 CapabilityExpr() : CapExpr(nullptr, 0) {}
285 CapabilityExpr(const til::SExpr *E, StringRef Kind, bool Neg, bool Reentrant)
286 : CapExpr(E, (Neg ? FlagNegative : 0) | (Reentrant ? FlagReentrant : 0)),
287 CapKind(Kind) {}
288 // Infers `Kind` and `Reentrant` from `QT`.
289 CapabilityExpr(const til::SExpr *E, QualType QT, bool Neg);
290
291 // Don't allow implicitly-constructed StringRefs since we'll capture them.
292 template <typename T>
293 CapabilityExpr(const til::SExpr *, T, bool, bool) = delete;
294
295 const til::SExpr *sexpr() const { return CapExpr.getPointer(); }
296 StringRef getKind() const { return CapKind; }
297 bool negative() const { return CapExpr.getInt() & FlagNegative; }
298 bool reentrant() const { return CapExpr.getInt() & FlagReentrant; }
299
301 return CapabilityExpr(CapExpr.getPointer(), CapKind, !negative(),
302 reentrant());
303 }
304
305 bool equals(const CapabilityExpr &other) const {
306 return (negative() == other.negative()) &&
307 sx::equals(sexpr(), other.sexpr());
308 }
309
310 bool matches(const CapabilityExpr &other) const {
311 return (negative() == other.negative()) &&
312 sx::matches(sexpr(), other.sexpr());
313 }
314
315 bool matchesUniv(const CapabilityExpr &CapE) const {
316 return isUniversal() || matches(CapE);
317 }
318
319 bool partiallyMatches(const CapabilityExpr &other) const {
320 return (negative() == other.negative()) &&
321 sx::partiallyMatches(sexpr(), other.sexpr());
322 }
323
324 const ValueDecl* valueDecl() const {
325 if (negative() || sexpr() == nullptr)
326 return nullptr;
327 if (const auto *P = dyn_cast<til::Project>(sexpr()))
328 return P->clangDecl();
329 if (const auto *P = dyn_cast<til::LiteralPtr>(sexpr()))
330 return P->clangDecl();
331 return nullptr;
332 }
333
334 std::string toString() const {
335 if (negative())
336 return "!" + sx::toString(sexpr());
337 return sx::toString(sexpr());
338 }
339
340 bool shouldIgnore() const { return sexpr() == nullptr; }
341
342 bool isInvalid() const { return isa_and_nonnull<til::Undefined>(sexpr()); }
343
344 bool isUniversal() const { return isa_and_nonnull<til::Wildcard>(sexpr()); }
345};
346
347// Translate clang::Expr to til::SExpr.
349public:
350 /// Encapsulates the lexical context of a function call. The lexical
351 /// context includes the arguments to the call, including the implicit object
352 /// argument. When an attribute containing a mutex expression is attached to
353 /// a method, the expression may refer to formal parameters of the method.
354 /// Actual arguments must be substituted for formal parameters to derive
355 /// the appropriate mutex expression in the lexical context where the function
356 /// is called. PrevCtx holds the context in which the arguments themselves
357 /// should be evaluated; multiple calling contexts can be chained together
358 /// by the lock_returned attribute.
360 // The previous context; or 0 if none.
362
363 // The decl to which the attr is attached.
365
366 // Implicit object argument -- e.g. 'this'
367 llvm::PointerUnion<const Expr *, til::SExpr *> SelfArg = nullptr;
368
369 // Number of funArgs
370 unsigned NumArgs = 0;
371
372 // Function arguments
373 llvm::PointerUnion<const Expr *const *, til::SExpr *> FunArgs = nullptr;
374
375 // is Self referred to with -> or .?
376 bool SelfArrow = false;
377
379 : Prev(P), AttrDecl(D) {}
380 };
381
383 // FIXME: we don't always have a self-variable.
384 SelfVar = new (Arena) til::Variable(nullptr);
385 SelfVar->setKind(til::Variable::VK_SFun);
386 }
387
388 // Create placeholder for this: we don't know the VarDecl on construction yet.
390 return new (Arena) til::LiteralPtr(nullptr);
391 }
392
393 // Translate a clang expression in an attribute to a til::SExpr.
394 // Constructs the context from D, DeclExp, and SelfDecl.
395 CapabilityExpr translateAttrExpr(const Expr *AttrExp, const NamedDecl *D,
396 const Expr *DeclExp,
397 til::SExpr *Self = nullptr);
398
400
401 // Translate a VarDecl to its canonical TIL expression.
403
404 // Translate a clang statement or expression to a TIL expression.
405 // Also performs substitution of variables; Ctx provides the context.
406 // Dispatches on the type of S.
407 til::SExpr *translate(const Stmt *S, CallingContext *Ctx);
408 til::SCFG *buildCFG(CFGWalker &Walker);
409
410 til::SExpr *lookupStmt(const Stmt *S);
411
413 return BlockMap[B->getBlockID()];
414 }
415
416 const til::SCFG *getCFG() const { return Scfg; }
417 til::SCFG *getCFG() { return Scfg; }
418
420 LookupLocalVarExpr = std::move(F);
421 }
422
423private:
424 // We implement the CFGVisitor API
425 friend class CFGWalker;
426
427 til::SExpr *translateDeclRefExpr(const DeclRefExpr *DRE,
428 CallingContext *Ctx) ;
429 til::SExpr *translateCXXThisExpr(const CXXThisExpr *TE, CallingContext *Ctx);
430 til::SExpr *translateMemberExpr(const MemberExpr *ME, CallingContext *Ctx);
431 til::SExpr *translateObjCIVarRefExpr(const ObjCIvarRefExpr *IVRE,
432 CallingContext *Ctx);
433 til::SExpr *translateCallExpr(const CallExpr *CE, CallingContext *Ctx,
434 const Expr *SelfE = nullptr);
435 til::SExpr *translateCXXMemberCallExpr(const CXXMemberCallExpr *ME,
436 CallingContext *Ctx);
437 til::SExpr *translateCXXOperatorCallExpr(const CXXOperatorCallExpr *OCE,
438 CallingContext *Ctx);
439 til::SExpr *translateUnaryOperator(const UnaryOperator *UO,
440 CallingContext *Ctx);
441 til::SExpr *translateBinOp(til::TIL_BinaryOpcode Op,
442 const BinaryOperator *BO,
443 CallingContext *Ctx, bool Reverse = false);
444 til::SExpr *translateBinAssign(til::TIL_BinaryOpcode Op,
445 const BinaryOperator *BO,
446 CallingContext *Ctx, bool Assign = false);
447 til::SExpr *translateBinaryOperator(const BinaryOperator *BO,
448 CallingContext *Ctx);
449 til::SExpr *translateCastExpr(const CastExpr *CE, CallingContext *Ctx);
450 til::SExpr *translateArraySubscriptExpr(const ArraySubscriptExpr *E,
451 CallingContext *Ctx);
452 til::SExpr *translateAbstractConditionalOperator(
454
455 til::SExpr *translateDeclStmt(const DeclStmt *S, CallingContext *Ctx);
456 til::SExpr *translateStmtExpr(const StmtExpr *SE, CallingContext *Ctx);
457
458 // Map from statements in the clang CFG to SExprs in the til::SCFG.
459 using StatementMap = llvm::DenseMap<const Stmt *, til::SExpr *>;
460
461 // Map from clang local variables to indices in a LVarDefinitionMap.
462 using LVarIndexMap = llvm::DenseMap<const ValueDecl *, unsigned>;
463
464 // Map from local variable indices to SSA variables (or constants).
465 using NameVarPair = std::pair<const ValueDecl *, til::SExpr *>;
466 using LVarDefinitionMap = CopyOnWriteVector<NameVarPair>;
467
468 struct BlockInfo {
469 LVarDefinitionMap ExitMap;
470 bool HasBackEdges = false;
471
472 // Successors yet to be processed
473 unsigned UnprocessedSuccessors = 0;
474
475 // Predecessors already processed
476 unsigned ProcessedPredecessors = 0;
477
478 BlockInfo() = default;
479 BlockInfo(BlockInfo &&) = default;
480 BlockInfo &operator=(BlockInfo &&) = default;
481 };
482
483 void enterCFG(CFG *Cfg, const NamedDecl *D, const CFGBlock *First);
484 void enterCFGBlock(const CFGBlock *B);
485 bool visitPredecessors() { return true; }
486 void handlePredecessor(const CFGBlock *Pred);
487 void handlePredecessorBackEdge(const CFGBlock *Pred);
488 void enterCFGBlockBody(const CFGBlock *B);
489 void handleStatement(const Stmt *S);
490 void handleDestructorCall(const VarDecl *VD, const CXXDestructorDecl *DD);
491 void exitCFGBlockBody(const CFGBlock *B);
492 bool visitSuccessors() { return true; }
493 void handleSuccessor(const CFGBlock *Succ);
494 void handleSuccessorBackEdge(const CFGBlock *Succ);
495 void exitCFGBlock(const CFGBlock *B);
496 void exitCFG(const CFGBlock *Last);
497
498 void insertStmt(const Stmt *S, til::SExpr *E) {
499 SMap.insert(std::make_pair(S, E));
500 }
501
502 til::SExpr *addStatement(til::SExpr *E, const Stmt *S,
503 const ValueDecl *VD = nullptr);
504 til::SExpr *lookupVarDecl(const ValueDecl *VD);
505 til::SExpr *addVarDecl(const ValueDecl *VD, til::SExpr *E);
506 til::SExpr *updateVarDecl(const ValueDecl *VD, til::SExpr *E);
507
508 void makePhiNodeVar(unsigned i, unsigned NPreds, til::SExpr *E);
509 void mergeEntryMap(LVarDefinitionMap Map);
510 void mergeEntryMapBackEdge();
511 void mergePhiNodesBackEdge(const CFGBlock *Blk);
512
513private:
514 // Set to true when parsing capability expressions, which get translated
515 // inaccurately in order to hack around smart pointers etc.
516 static const bool CapabilityExprMode = true;
517
518 til::MemRegionRef Arena;
519
520 // Variable to use for 'this'. May be null.
521 til::Variable *SelfVar = nullptr;
522
523 til::SCFG *Scfg = nullptr;
524
525 // Map from Stmt to TIL Variables
526 StatementMap SMap;
527
528 // Indices of clang local vars.
529 LVarIndexMap LVarIdxMap;
530
531 // Map from clang to til BBs.
532 std::vector<til::BasicBlock *> BlockMap;
533
534 // Extra information per BB. Indexed by clang BlockID.
535 std::vector<BlockInfo> BBInfo;
536
537 LVarDefinitionMap CurrentLVarMap;
538 std::vector<til::Phi *> CurrentArguments;
539 std::vector<til::SExpr *> CurrentInstructions;
540 std::vector<til::Phi *> IncompleteArgs;
541 til::BasicBlock *CurrentBB = nullptr;
542 BlockInfo *CurrentBlockInfo = nullptr;
543
544 // The closure that captures state required for the lookup; this may be
545 // mutable, so we have to save/restore before/after recursive lookups.
546 using LookupLocalVarExprClosure =
547 std::function<const Expr *(const NamedDecl *)>;
548 // Recursion guard.
549 llvm::DenseSet<const ValueDecl *> VarsBeingTranslated;
550 // Context-dependent lookup of currently valid definitions of local variables.
551 LookupLocalVarExprClosure LookupLocalVarExpr;
552};
553
554#ifndef NDEBUG
555// Dump an SCFG to llvm::errs().
556void printSCFG(CFGWalker &Walker);
557#endif // NDEBUG
558
559} // namespace threadSafety
560} // namespace clang
561
562#endif // LLVM_CLANG_ANALYSIS_ANALYSES_THREADSAFETYCOMMON_H
#define V(N, I)
This file defines AnalysisDeclContext, a class that manages the analysis context data for context sen...
llvm::DenseMap< const Stmt *, CFGBlock * > SMap
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
SExprBuilder::CallingContext CallingContext
C Language Family Type Representation.
AbstractConditionalOperator - An abstract base class for ConditionalOperator and BinaryConditionalOpe...
Definition Expr.h:4287
AnalysisDeclContext contains the context data for the function, method or block under analysis.
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Definition Expr.h:2721
A builtin binary operation expression such as "x + y" or "x <= y".
Definition Expr.h:3972
Represents C++ object destructor implicitly generated for automatic object or temporary bound to cons...
Definition CFG.h:418
const VarDecl * getVarDecl() const
Definition CFG.h:423
Represents a single basic block in a source-level CFG.
Definition CFG.h:605
AdjacentBlocks::const_iterator const_pred_iterator
Definition CFG.h:959
unsigned getBlockID() const
Definition CFG.h:1107
AdjacentBlocks::const_iterator const_succ_iterator
Definition CFG.h:966
@ AutomaticObjectDtor
Definition CFG.h:72
T castAs() const
Convert to the specified CFGElement type, asserting that this CFGElement is of the desired type.
Definition CFG.h:99
const CXXDestructorDecl * getDestructorDecl(ASTContext &astContext) const
Definition CFG.cpp:5412
const Stmt * getStmt() const
Definition CFG.h:139
Represents a source-level, intra-procedural CFG that represents the control-flow of a Stmt.
Definition CFG.h:1218
Represents a C++ destructor within a class.
Definition DeclCXX.h:2869
Represents a call to a member function that may be written either with member call syntax (e....
Definition ExprCXX.h:179
A call to an overloaded operator written using operator syntax.
Definition ExprCXX.h:84
Represents the this expression in C++.
Definition ExprCXX.h:1154
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition Expr.h:2877
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Definition Expr.h:3610
A reference to a declared variable, function, enum, etc.
Definition Expr.h:1270
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
Definition Stmt.h:1621
This represents one expression.
Definition Expr.h:112
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition Expr.h:3298
This represents a decl that may have a name.
Definition Decl.h:274
ObjCIvarRefExpr - A reference to an ObjC instance variable.
Definition ExprObjC.h:546
Implements a set of CFGBlocks using a BitVector.
std::pair< std::nullopt_t, bool > insert(const CFGBlock *Block)
Set the bit associated with a particular CFGBlock.
bool alreadySet(const CFGBlock *Block)
Check if the bit for a CFGBlock has been already set.
A (possibly-)qualified type.
Definition TypeBase.h:937
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
Definition Expr.h:4529
Stmt - This represents one statement.
Definition Stmt.h:85
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Definition Expr.h:2244
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition Decl.h:712
Represents a variable declaration or definition.
Definition Decl.h:926
const PostOrderCFGView * getSortedGraph() const
const NamedDecl * getDecl() const
bool init(AnalysisDeclContext &AC)
CapabilityExpr(const til::SExpr *E, StringRef Kind, bool Neg, bool Reentrant)
CapabilityExpr(const til::SExpr *, T, bool, bool)=delete
bool matches(const CapabilityExpr &other) const
bool partiallyMatches(const CapabilityExpr &other) const
bool equals(const CapabilityExpr &other) const
bool matchesUniv(const CapabilityExpr &CapE) const
CapabilityExpr translateAttrExpr(const Expr *AttrExp, const NamedDecl *D, const Expr *DeclExp, til::SExpr *Self=nullptr)
Translate a clang expression in an attribute to a til::SExpr.
void setLookupLocalVarExpr(std::function< const Expr *(const NamedDecl *)> F)
til::SExpr * translate(const Stmt *S, CallingContext *Ctx)
til::SExpr * lookupStmt(const Stmt *S)
til::SCFG * buildCFG(CFGWalker &Walker)
til::SExpr * translateVariable(const VarDecl *VD, CallingContext *Ctx)
til::BasicBlock * lookupBlock(const CFGBlock *B)
A basic block is part of an SCFG.
static bool compareExprs(const SExpr *E1, const SExpr *E2)
A Literal pointer to an object allocated in memory.
static bool compareExprs(const SExpr *E1, const SExpr *E2)
An SCFG is a control-flow graph.
Base class for AST nodes in the typed intermediate language.
@ VK_SFun
SFunction (self) parameter.
bool matches(const til::SExpr *E1, const til::SExpr *E2)
bool equals(const til::SExpr *E1, const til::SExpr *E2)
std::string toString(const til::SExpr *E)
bool partiallyMatches(const til::SExpr *E1, const til::SExpr *E2)
TIL_BinaryOpcode
Opcode for binary arithmetic operations.
void printSCFG(CFGWalker &Walker)
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
Definition Address.h:330
@ Self
'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
const FunctionProtoType * T
int const char * function
Definition c++config.h:31
Encapsulates the lexical context of a function call.
llvm::PointerUnion< const Expr *const *, til::SExpr * > FunArgs
CallingContext(CallingContext *P, const NamedDecl *D=nullptr)
llvm::PointerUnion< const Expr *, til::SExpr * > SelfArg