Skip to content

Commit b70b014

Browse files
committed
review feedback target check
Signed-off-by: Nathan Gauër <[email protected]>
1 parent a733a2c commit b70b014

File tree

4 files changed

+18
-12
lines changed

4 files changed

+18
-12
lines changed

clang/lib/CodeGen/CGCall.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4831,7 +4831,7 @@ llvm::CallInst *CodeGenFunction::EmitRuntimeCall(llvm::FunctionCallee callee,
48314831
callee, args, getBundlesForFunclet(callee.getCallee()), name);
48324832
call->setCallingConv(getRuntimeCC());
48334833

4834-
if (getTarget().getTriple().isSPIRVLogical() && call->isConvergent())
4834+
if (CGM.shouldEmitConvergenceTokens() && call->isConvergent())
48354835
return addControlledConvergenceToken(call);
48364836
return call;
48374837
}
@@ -5733,7 +5733,7 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
57335733
if (!CI->getType()->isVoidTy())
57345734
CI->setName("call");
57355735

5736-
if (getTarget().getTriple().isSPIRVLogical() && CI->isConvergent())
5736+
if (CGM.shouldEmitConvergenceTokens() && CI->isConvergent())
57375737
CI = addControlledConvergenceToken(CI);
57385738

57395739
// Update largest vector width from the return type.

clang/lib/CodeGen/CGStmt.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,7 @@ void CodeGenFunction::EmitWhileStmt(const WhileStmt &S,
978978
JumpDest LoopHeader = getJumpDestInCurrentScope("while.cond");
979979
EmitBlock(LoopHeader.getBlock());
980980

981-
if (getTarget().getTriple().isSPIRVLogical())
981+
if (CGM.shouldEmitConvergenceTokens())
982982
ConvergenceTokenStack.push_back(emitConvergenceLoopToken(
983983
LoopHeader.getBlock(), ConvergenceTokenStack.back()));
984984

@@ -1084,7 +1084,7 @@ void CodeGenFunction::EmitWhileStmt(const WhileStmt &S,
10841084
if (llvm::EnableSingleByteCoverage)
10851085
incrementProfileCounter(&S);
10861086

1087-
if (getTarget().getTriple().isSPIRVLogical())
1087+
if (CGM.shouldEmitConvergenceTokens())
10881088
ConvergenceTokenStack.pop_back();
10891089
}
10901090

@@ -1106,7 +1106,7 @@ void CodeGenFunction::EmitDoStmt(const DoStmt &S,
11061106
else
11071107
EmitBlockWithFallThrough(LoopBody, &S);
11081108

1109-
if (getTarget().getTriple().isSPIRVLogical())
1109+
if (CGM.shouldEmitConvergenceTokens())
11101110
ConvergenceTokenStack.push_back(
11111111
emitConvergenceLoopToken(LoopBody, ConvergenceTokenStack.back()));
11121112

@@ -1164,7 +1164,7 @@ void CodeGenFunction::EmitDoStmt(const DoStmt &S,
11641164
if (llvm::EnableSingleByteCoverage)
11651165
incrementProfileCounter(&S);
11661166

1167-
if (getTarget().getTriple().isSPIRVLogical())
1167+
if (CGM.shouldEmitConvergenceTokens())
11681168
ConvergenceTokenStack.pop_back();
11691169
}
11701170

@@ -1185,7 +1185,7 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S,
11851185
llvm::BasicBlock *CondBlock = CondDest.getBlock();
11861186
EmitBlock(CondBlock);
11871187

1188-
if (getTarget().getTriple().isSPIRVLogical())
1188+
if (CGM.shouldEmitConvergenceTokens())
11891189
ConvergenceTokenStack.push_back(
11901190
emitConvergenceLoopToken(CondBlock, ConvergenceTokenStack.back()));
11911191

@@ -1299,7 +1299,7 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S,
12991299
if (llvm::EnableSingleByteCoverage)
13001300
incrementProfileCounter(&S);
13011301

1302-
if (getTarget().getTriple().isSPIRVLogical())
1302+
if (CGM.shouldEmitConvergenceTokens())
13031303
ConvergenceTokenStack.pop_back();
13041304
}
13051305

@@ -1323,7 +1323,7 @@ CodeGenFunction::EmitCXXForRangeStmt(const CXXForRangeStmt &S,
13231323
llvm::BasicBlock *CondBlock = createBasicBlock("for.cond");
13241324
EmitBlock(CondBlock);
13251325

1326-
if (getTarget().getTriple().isSPIRVLogical())
1326+
if (CGM.shouldEmitConvergenceTokens())
13271327
ConvergenceTokenStack.push_back(
13281328
emitConvergenceLoopToken(CondBlock, ConvergenceTokenStack.back()));
13291329

@@ -1396,7 +1396,7 @@ CodeGenFunction::EmitCXXForRangeStmt(const CXXForRangeStmt &S,
13961396
if (llvm::EnableSingleByteCoverage)
13971397
incrementProfileCounter(&S);
13981398

1399-
if (getTarget().getTriple().isSPIRVLogical())
1399+
if (CGM.shouldEmitConvergenceTokens())
14001400
ConvergenceTokenStack.pop_back();
14011401
}
14021402

clang/lib/CodeGen/CodeGenFunction.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) {
353353
assert(DeferredDeactivationCleanupStack.empty() &&
354354
"mismatched activate/deactivate of cleanups!");
355355

356-
if (getTarget().getTriple().isSPIRVLogical()) {
356+
if (CGM.shouldEmitConvergenceTokens()) {
357357
ConvergenceTokenStack.pop_back();
358358
assert(ConvergenceTokenStack.empty() &&
359359
"mismatched push/pop in convergence stack!");
@@ -1284,7 +1284,7 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy,
12841284
if (const auto *VecWidth = CurFuncDecl->getAttr<MinVectorWidthAttr>())
12851285
LargestVectorWidth = VecWidth->getVectorWidth();
12861286

1287-
if (getTarget().getTriple().isSPIRVLogical())
1287+
if (CGM.shouldEmitConvergenceTokens())
12881288
ConvergenceTokenStack.push_back(getOrEmitConvergenceEntryToken(CurFn));
12891289
}
12901290

clang/lib/CodeGen/CodeGenModule.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1586,6 +1586,12 @@ class CodeGenModule : public CodeGenTypeCache {
15861586
void AddGlobalDtor(llvm::Function *Dtor, int Priority = 65535,
15871587
bool IsDtorAttrFunc = false);
15881588

1589+
// Return whether structured convergence intrinsics should be generated for
1590+
// this target.
1591+
bool shouldEmitConvergenceTokens() const {
1592+
return getTriple().isSPIRVLogical();
1593+
}
1594+
15891595
private:
15901596
llvm::Constant *GetOrCreateLLVMFunction(
15911597
StringRef MangledName, llvm::Type *Ty, GlobalDecl D, bool ForVTable,

0 commit comments

Comments
 (0)