Skip to content

Commit 1b01f05

Browse files
authored
[NVPTX] Make GlobalUniqueCallSite a member of NVPTXISelLowering (#130212)
This change moves GlobalUniqueCallSite into NVPTXISelLowering. In processes where multiple compilations occur, this makes call site enumeration local to individual compilation, which ensures that call site numbers are consistently sequential within each compilation and is independent of other compilations happening in parallel.
1 parent 8c130b1 commit 1b01f05

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@
7373

7474
using namespace llvm;
7575

76-
static std::atomic<unsigned> GlobalUniqueCallSite;
77-
7876
static cl::opt<bool> sched4reg(
7977
"nvptx-sched4reg",
8078
cl::desc("NVPTX Specific: schedule for register pressue"), cl::init(false));
@@ -500,7 +498,7 @@ static SDValue MaybeBitcast(SelectionDAG &DAG, SDLoc DL, EVT VT,
500498
// NVPTXTargetLowering Constructor.
501499
NVPTXTargetLowering::NVPTXTargetLowering(const NVPTXTargetMachine &TM,
502500
const NVPTXSubtarget &STI)
503-
: TargetLowering(TM), nvTM(&TM), STI(STI) {
501+
: TargetLowering(TM), nvTM(&TM), STI(STI), GlobalUniqueCallSite(0) {
504502
// always lower memset, memcpy, and memmove intrinsics to load/store
505503
// instructions, rather
506504
// then generating calls to memset, mempcy or memmove.
@@ -1474,7 +1472,7 @@ SDValue NVPTXTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
14741472
unsigned FirstVAArg = CLI.NumFixedArgs; // position of the first variadic
14751473
unsigned VAOffset = 0; // current offset in the param array
14761474

1477-
unsigned UniqueCallSite = GlobalUniqueCallSite.fetch_add(1);
1475+
const unsigned UniqueCallSite = GlobalUniqueCallSite++;
14781476
SDValue TempChain = Chain;
14791477
Chain = DAG.getCALLSEQ_START(Chain, UniqueCallSite, 0, dl);
14801478
SDValue InGlue = Chain.getValue(1);

llvm/lib/Target/NVPTX/NVPTXISelLowering.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,8 @@ class NVPTXTargetLowering : public TargetLowering {
273273

274274
private:
275275
const NVPTXSubtarget &STI; // cache the subtarget here
276+
mutable unsigned GlobalUniqueCallSite;
277+
276278
SDValue getParamSymbol(SelectionDAG &DAG, int idx, EVT) const;
277279

278280
SDValue LowerADDRSPACECAST(SDValue Op, SelectionDAG &DAG) const;

0 commit comments

Comments
 (0)