Skip to content

Commit 2494ad3

Browse files
committed
correctly use unique + comments
1 parent c106a8c commit 2494ad3

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
@@ -18414,7 +18414,7 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned BuiltinID,
1841418414
return nullptr;
1841518415
}
1841618416

18417-
void CodeGenFunction::AddAMDGCNFenceAddressSpaceMMRA(llvm::Instruction *Inst,
18417+
void CodeGenFunction::AddAMDGPUFenceAddressSpaceMMRA(llvm::Instruction *Inst,
1841818418
const CallExpr *E) {
1841918419
constexpr const char *Tag = "amdgpu-as";
1842018420

@@ -18432,7 +18432,8 @@ void CodeGenFunction::AddAMDGCNFenceAddressSpaceMMRA(llvm::Instruction *Inst,
1843218432
"expected an address space name as a string literal");
1843318433
}
1843418434

18435-
llvm::unique(MMRAs);
18435+
llvm::sort(MMRAs);
18436+
MMRAs.erase(llvm::unique(MMRAs), MMRAs.end());
1843618437
Inst->setMetadata(LLVMContext::MD_mmra, MMRAMetadata::getMD(Ctx, MMRAs));
1843718438
}
1843818439

@@ -19108,7 +19109,7 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned BuiltinID,
1910819109
EmitScalarExpr(E->getArg(1)), AO, SSID);
1910919110
FenceInst *Fence = Builder.CreateFence(AO, SSID);
1911019111
if (E->getNumArgs() > 2)
19111-
AddAMDGCNFenceAddressSpaceMMRA(Fence, E);
19112+
AddAMDGPUFenceAddressSpaceMMRA(Fence, E);
1911219113
return Fence;
1911319114
}
1911419115
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
@@ -4632,7 +4632,7 @@ class CodeGenFunction : public CodeGenTypeCache {
46324632
llvm::Value *EmitRISCVBuiltinExpr(unsigned BuiltinID, const CallExpr *E,
46334633
ReturnValueSlot ReturnValue);
46344634

4635-
void AddAMDGCNFenceAddressSpaceMMRA(llvm::Instruction *Inst,
4635+
void AddAMDGPUFenceAddressSpaceMMRA(llvm::Instruction *Inst,
46364636
const CallExpr *E);
46374637
void ProcessOrderScopeAMDGCN(llvm::Value *Order, llvm::Value *Scope,
46384638
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)