Skip to content

Commit fe7cb15

Browse files
[SPIR-V] Improve portability of the code (#123584)
Adding SPIRV to LLVM_ALL_TARGETS (#119653) revealed a series of minor compilation problems and sanitizer complaints. This PR is to address the problem.
1 parent 96c4f97 commit fe7cb15

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

llvm/lib/Target/SPIRV/SPIRVBuiltins.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -535,15 +535,15 @@ extern Register insertAssignInstr(Register Reg, Type *Ty, SPIRVType *SpirvTy,
535535
static SPIRV::MemorySemantics::MemorySemantics
536536
getSPIRVMemSemantics(std::memory_order MemOrder) {
537537
switch (MemOrder) {
538-
case std::memory_order::memory_order_relaxed:
538+
case std::memory_order_relaxed:
539539
return SPIRV::MemorySemantics::None;
540-
case std::memory_order::memory_order_acquire:
540+
case std::memory_order_acquire:
541541
return SPIRV::MemorySemantics::Acquire;
542-
case std::memory_order::memory_order_release:
542+
case std::memory_order_release:
543543
return SPIRV::MemorySemantics::Release;
544-
case std::memory_order::memory_order_acq_rel:
544+
case std::memory_order_acq_rel:
545545
return SPIRV::MemorySemantics::AcquireRelease;
546-
case std::memory_order::memory_order_seq_cst:
546+
case std::memory_order_seq_cst:
547547
return SPIRV::MemorySemantics::SequentiallyConsistent;
548548
default:
549549
report_fatal_error("Unknown CL memory scope");

llvm/lib/Target/SPIRV/SPIRVPrepareFunctions.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "SPIRVSubtarget.h"
2323
#include "SPIRVTargetMachine.h"
2424
#include "SPIRVUtils.h"
25+
#include "llvm/ADT/StringExtras.h"
2526
#include "llvm/Analysis/ValueTracking.h"
2627
#include "llvm/CodeGen/IntrinsicLowering.h"
2728
#include "llvm/IR/IRBuilder.h"
@@ -30,7 +31,6 @@
3031
#include "llvm/IR/IntrinsicsSPIRV.h"
3132
#include "llvm/Transforms/Utils/Cloning.h"
3233
#include "llvm/Transforms/Utils/LowerMemIntrinsics.h"
33-
#include <charconv>
3434
#include <regex>
3535

3636
using namespace llvm;
@@ -228,9 +228,7 @@ static SmallVector<Metadata *> parseAnnotation(Value *I,
228228
} else {
229229
MDsItem.push_back(MDString::get(Ctx, Item));
230230
}
231-
} else if (int32_t Num;
232-
std::from_chars(Item.data(), Item.data() + Item.size(), Num)
233-
.ec == std::errc{}) {
231+
} else if (int32_t Num; llvm::to_integer(StringRef(Item), Num, 10)) {
234232
MDsItem.push_back(
235233
ConstantAsMetadata::get(ConstantInt::get(Int32Ty, Num)));
236234
} else {

llvm/lib/Target/SPIRV/SPIRVUtils.h

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "llvm/IR/TypedPointerType.h"
2323
#include <queue>
2424
#include <string>
25+
#include <unordered_map>
2526
#include <unordered_set>
2627

2728
namespace llvm {

0 commit comments

Comments
 (0)