Skip to content

Commit a05d4cd

Browse files
committed
correctly use unique + comments
1 parent c6ba3da commit a05d4cd

File tree

5 files changed

+14
-16
lines changed

5 files changed

+14
-16
lines changed

clang/docs/LanguageExtensions.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4432,7 +4432,8 @@ The address spaces arguments must be string literals with known values, such as:
44324432
* ``"image"``
44334433
44344434
If one or more address space name are provided, the code generator will attempt
4435-
to emit potentially faster instructions that only fence those address spaces.
4435+
to emit potentially faster instructions that order access to at least those
4436+
address spaces.
44364437
Emitting such instructions may not always be possible and the compiler is free
44374438
to fence more aggressively.
44384439

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18328,7 +18328,7 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned BuiltinID,
1832818328
return nullptr;
1832918329
}
1833018330

18331-
void CodeGenFunction::AddAMDGCNFenceAddressSpaceMMRA(llvm::Instruction *Inst,
18331+
void CodeGenFunction::AddAMDGPUFenceAddressSpaceMMRA(llvm::Instruction *Inst,
1833218332
const CallExpr *E) {
1833318333
constexpr const char *Tag = "amdgpu-as";
1833418334

@@ -18346,7 +18346,8 @@ void CodeGenFunction::AddAMDGCNFenceAddressSpaceMMRA(llvm::Instruction *Inst,
1834618346
"expected an address space name as a string literal");
1834718347
}
1834818348

18349-
llvm::unique(MMRAs);
18349+
llvm::sort(MMRAs);
18350+
MMRAs.erase(llvm::unique(MMRAs), MMRAs.end());
1835018351
Inst->setMetadata(LLVMContext::MD_mmra, MMRAMetadata::getMD(Ctx, MMRAs));
1835118352
}
1835218353

@@ -19022,7 +19023,7 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned BuiltinID,
1902219023
EmitScalarExpr(E->getArg(1)), AO, SSID);
1902319024
FenceInst *Fence = Builder.CreateFence(AO, SSID);
1902419025
if (E->getNumArgs() > 2)
19025-
AddAMDGCNFenceAddressSpaceMMRA(Fence, E);
19026+
AddAMDGPUFenceAddressSpaceMMRA(Fence, E);
1902619027
return Fence;
1902719028
}
1902819029
case AMDGPU::BI__builtin_amdgcn_atomic_inc32:

clang/lib/CodeGen/CodeGenFunction.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4636,7 +4636,7 @@ class CodeGenFunction : public CodeGenTypeCache {
46364636
llvm::Value *EmitRISCVBuiltinExpr(unsigned BuiltinID, const CallExpr *E,
46374637
ReturnValueSlot ReturnValue);
46384638

4639-
void AddAMDGCNFenceAddressSpaceMMRA(llvm::Instruction *Inst,
4639+
void AddAMDGPUFenceAddressSpaceMMRA(llvm::Instruction *Inst,
46404640
const CallExpr *E);
46414641
void ProcessOrderScopeAMDGCN(llvm::Value *Order, llvm::Value *Scope,
46424642
llvm::AtomicOrdering &AO,

clang/test/CodeGenCXX/builtin-amdgcn-fence.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,12 @@ void test_image() {
102102
//
103103
void test_mixed() {
104104
__builtin_amdgcn_fence( __ATOMIC_SEQ_CST, "workgroup", "image", "global");
105-
__builtin_amdgcn_fence( __ATOMIC_SEQ_CST, "workgroup", "image", "local", "global");
105+
__builtin_amdgcn_fence( __ATOMIC_SEQ_CST, "workgroup", "image", "local", "global", "image", "image");
106106
}
107107
//.
108108
// CHECK: [[META3]] = !{!"amdgpu-as", !"local"}
109109
// CHECK: [[META4]] = !{!"amdgpu-as", !"global"}
110110
// CHECK: [[META5]] = !{!"amdgpu-as", !"image"}
111-
// CHECK: [[META6]] = !{[[META5]], [[META4]]}
112-
// CHECK: [[META7]] = !{[[META5]], [[META3]], [[META4]]}
111+
// CHECK: [[META6]] = !{[[META4]], [[META5]]}
112+
// CHECK: [[META7]] = !{[[META4]], [[META5]], [[META3]]}
113113
//.

llvm/lib/Target/AMDGPU/SIMemoryLegalizer.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "GCNSubtarget.h"
1919
#include "MCTargetDesc/AMDGPUMCTargetDesc.h"
2020
#include "llvm/ADT/BitmaskEnum.h"
21+
#include "llvm/ADT/StringExtras.h"
2122
#include "llvm/CodeGen/MachineBasicBlock.h"
2223
#include "llvm/CodeGen/MachineFunctionPass.h"
2324
#include "llvm/IR/DiagnosticInfo.h"
@@ -691,14 +692,9 @@ void diagnoseUnknownMMRAASName(const MachineInstr &MI, StringRef AS) {
691692
std::string Str;
692693
raw_string_ostream OS(Str);
693694
OS << "unknown address space '" << AS << "'; expected one of ";
694-
bool IsFirst = true;
695-
for (const auto &[Name, Val] : ASNames) {
696-
if (IsFirst)
697-
IsFirst = false;
698-
else
699-
OS << ", ";
700-
OS << '\'' << Name << '\'';
701-
}
695+
ListSeparator LS;
696+
for (const auto &[Name, Val] : ASNames)
697+
OS << LS << '\'' << Name << '\'';
702698
DiagnosticInfoUnsupported BadTag(Fn, Str, MI.getDebugLoc(), DS_Warning);
703699
Fn.getContext().diagnose(BadTag);
704700
}

0 commit comments

Comments
 (0)