Skip to content

Commit 1eb371d

Browse files
committed
[NVPTX] Print SyncScope ID string if out of bounds
1 parent 82237ec commit 1eb371d

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4176,7 +4176,7 @@ bool NVPTXDAGToDAGISel::tryFence(SDNode *N) {
41764176
return true;
41774177
}
41784178

4179-
NVPTXScopes::NVPTXScopes(LLVMContext &C) {
4179+
NVPTXScopes::NVPTXScopes(LLVMContext &C) : CTX(&C) {
41804180
Scopes[C.getOrInsertSyncScopeID("singlethread")] = NVPTX::Scope::Thread;
41814181
Scopes[C.getOrInsertSyncScopeID("")] = NVPTX::Scope::System;
41824182
Scopes[C.getOrInsertSyncScopeID("block")] = NVPTX::Scope::Block;
@@ -4190,13 +4190,11 @@ NVPTX::Scope NVPTXScopes::operator[](SyncScope::ID ID) const {
41904190
"NVPTXScopes::operator[]");
41914191

41924192
auto S = Scopes.find(ID);
4193-
if (S == Scopes.end()) {
4194-
// TODO:
4195-
// - Add API to LLVMContext to get the name of a single scope.
4196-
// - Use that API here to print an error containing the name
4197-
// of this Unknown ID.
4198-
report_fatal_error(formatv("Could not find scope ID={}.", int(ID)));
4199-
}
4193+
if (S == Scopes.end())
4194+
report_fatal_error(
4195+
formatv("Could not find scope ID={} with name \"{}\".", int(ID),
4196+
CTX->getSyncScopeName(ID).value_or("unknown")));
4197+
42004198
return S->second;
42014199
}
42024200

llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ struct NVPTXScopes {
3535

3636
private:
3737
SmallMapVector<SyncScope::ID, NVPTX::Scope, 8> Scopes{};
38+
LLVMContext *CTX = nullptr;
3839
};
3940

4041
class LLVM_LIBRARY_VISIBILITY NVPTXDAGToDAGISel : public SelectionDAGISel {

0 commit comments

Comments
 (0)