aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenFunction.h
diff options
context:
space:
mode:
authorNathan Gauër <brioche@google.com>2024-05-14 17:00:40 +0200
committerGitHub <noreply@github.com>2024-05-14 17:00:40 +0200
commite08f1fda7508138d408cd61608bcbf30f8c3bb4d (patch)
tree5708a1d5a1b975ee35be54b33ecccc66ed8c8281 /clang/lib/CodeGen/CodeGenFunction.h
parenta4accdfe0c9415ad1bd3dac7dda8cb8bbcd1be2f (diff)
downloadllvm-e08f1fda7508138d408cd61608bcbf30f8c3bb4d.zip
llvm-e08f1fda7508138d408cd61608bcbf30f8c3bb4d.tar.gz
llvm-e08f1fda7508138d408cd61608bcbf30f8c3bb4d.tar.bz2
[clang][SPIR-V] Always add convergence intrinsics (#88918)
PR #80680 added bits in the codegen to lazily add convergence intrinsics when required. This logic relied on the LoopStack. The issue is when parsing the condition, the loopstack doesn't yet reflect the correct values, as expected since we are not yet in the loop. However, convergence tokens should sometimes already be available. The solution which seemed the simplest is to greedily generate the tokens when we generate SPIR-V. Fixes #88144 --------- Signed-off-by: Nathan Gauër <brioche@google.com>
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.h')
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index e1e687a..362f4a5 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -315,6 +315,9 @@ public:
/// Stack to track the Logical Operator recursion nest for MC/DC.
SmallVector<const BinaryOperator *, 16> MCDCLogOpStack;
+ /// Stack to track the controlled convergence tokens.
+ SmallVector<llvm::IntrinsicInst *, 4> ConvergenceTokenStack;
+
/// Number of nested loop to be consumed by the last surrounding
/// loop-associated directive.
int ExpectedOMPLoopDepth = 0;
@@ -5076,7 +5079,11 @@ public:
const llvm::Twine &Name = "");
// Adds a convergence_ctrl token to |Input| and emits the required parent
// convergence instructions.
- llvm::CallBase *addControlledConvergenceToken(llvm::CallBase *Input);
+ template <typename CallType>
+ CallType *addControlledConvergenceToken(CallType *Input) {
+ return cast<CallType>(
+ addConvergenceControlToken(Input, ConvergenceTokenStack.back()));
+ }
private:
// Emits a convergence_loop instruction for the given |BB|, with |ParentToken|