Skip to content

Commit ad85118

Browse files
committed
[TPDE][LLVM] Drop noexcept
We compile with -fno-exceptions, so noexcept has no impact anyway.
1 parent fb0601b commit ad85118

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1241
-1446
lines changed

tpde-encodegen/src/arm64/EncCompilerTemplate.hpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ struct EncodeCompiler {
5454
using ValuePart = typename CompilerA64::ValuePart;
5555
using GenericValuePart = typename CompilerA64::GenericValuePart;
5656
57-
std::optional<u64> encodeable_as_shiftimm(GenericValuePart &gv, unsigned size) const noexcept {
57+
std::optional<u64> encodeable_as_shiftimm(GenericValuePart &gv, unsigned size) const {
5858
if (gv.is_imm() && gv.imm_size() <= 8) {
5959
return gv.imm64() & (size - 1);
6060
}
6161
return std::nullopt;
6262
}
63-
std::optional<u64> encodeable_as_immarith(GenericValuePart &gv) const noexcept {
63+
std::optional<u64> encodeable_as_immarith(GenericValuePart &gv) const {
6464
if (gv.is_imm() && gv.imm_size() <= 8) {
6565
u64 val = gv.imm64();
6666
val = static_cast<i64>(val) < 0 ? -val : val;
@@ -70,7 +70,7 @@ struct EncodeCompiler {
7070
}
7171
return std::nullopt;
7272
}
73-
std::optional<u64> encodeable_as_immlogical(GenericValuePart &gv, bool inv) const noexcept {
73+
std::optional<u64> encodeable_as_immlogical(GenericValuePart &gv, bool inv) const {
7474
if (gv.is_imm()) {
7575
u64 imm = gv.imm64() ^ (inv ? ~u64{0} : 0);
7676
if (gv.imm_size() == 8 && de64_ANDxi(DA_GP(0), DA_GP(0), imm))
@@ -80,22 +80,22 @@ struct EncodeCompiler {
8080
}
8181
return std::nullopt;
8282
}
83-
std::optional<std::pair<AsmReg, u64>> encodeable_with_mem_uoff12(GenericValuePart &gv, u64 off, unsigned shift) noexcept;
83+
std::optional<std::pair<AsmReg, u64>> encodeable_with_mem_uoff12(GenericValuePart &gv, u64 off, unsigned shift);
8484
8585
void try_salvage_or_materialize(GenericValuePart &gv,
8686
ScratchReg &dst_scratch,
8787
u8 bank,
88-
u32 size) noexcept;
88+
u32 size);
8989
void try_salvage_or_materialize(GenericValuePart &gv,
9090
ValuePart &dst_scratch,
9191
u8 bank,
92-
u32 size) noexcept;
92+
u32 size);
9393
94-
CompilerA64 *derived() noexcept {
94+
CompilerA64 *derived() {
9595
return static_cast<CompilerA64 *>(static_cast<Derived *>(this));
9696
}
9797
98-
const CompilerA64 *derived() const noexcept {
98+
const CompilerA64 *derived() const {
9999
return static_cast<const CompilerA64 *>(
100100
static_cast<const Derived *>(this));
101101
}
@@ -110,13 +110,13 @@ struct EncodeCompiler {
110110
void scratch_alloc_specific(AsmReg reg,
111111
ScratchReg &scratch,
112112
std::initializer_list<GenericValuePart *> operands,
113-
FixedRegBackup &backup_reg) noexcept;
113+
FixedRegBackup &backup_reg);
114114
115115
void scratch_check_fixed_backup(ScratchReg &scratch,
116116
FixedRegBackup &backup_reg,
117-
bool is_ret_reg) noexcept;
117+
bool is_ret_reg);
118118
119-
void reset() noexcept {
119+
void reset() {
120120
symbols.fill({});
121121
}
122122
@@ -142,7 +142,7 @@ template <typename Adaptor,
142142
class BaseTy,
143143
typename Config>
144144
std::optional<std::pair<typename EncodeCompiler<Adaptor, Derived, BaseTy, Config>::AsmReg, u64>> EncodeCompiler<Adaptor, Derived, BaseTy, Config>::
145-
encodeable_with_mem_uoff12(GenericValuePart &gv, u64 off, unsigned shift) noexcept {
145+
encodeable_with_mem_uoff12(GenericValuePart &gv, u64 off, unsigned shift) {
146146
auto *expr = std::get_if<typename GenericValuePart::Expr>(&gv.state);
147147
if (!expr || !expr->has_base()) {
148148
return std::nullopt;
@@ -197,7 +197,7 @@ void EncodeCompiler<Adaptor, Derived, BaseTy, Config>::
197197
try_salvage_or_materialize(GenericValuePart &gv,
198198
ScratchReg &dst_scratch,
199199
u8 bank,
200-
u32 size) noexcept {
200+
u32 size) {
201201
AsmReg reg = derived()->gval_as_reg_reuse(gv, dst_scratch);
202202
if (!dst_scratch.has_reg()) {
203203
dst_scratch.alloc(RegBank(bank));
@@ -216,7 +216,7 @@ void EncodeCompiler<Adaptor, Derived, BaseTy, Config>::
216216
try_salvage_or_materialize(GenericValuePart &gv,
217217
ValuePart &dst_scratch,
218218
u8 ,
219-
u32 size) noexcept {
219+
u32 size) {
220220
AsmReg reg = derived()->gval_as_reg_reuse(gv, dst_scratch);
221221
if (!dst_scratch.has_reg()) {
222222
dst_scratch.alloc_reg(derived());
@@ -235,7 +235,7 @@ void EncodeCompiler<Adaptor, Derived, BaseTy, Config>::scratch_alloc_specific(
235235
AsmReg reg,
236236
ScratchReg &scratch,
237237
std::initializer_list<GenericValuePart *> operands,
238-
FixedRegBackup &backup_reg) noexcept {
238+
FixedRegBackup &backup_reg) {
239239
if (!derived()->register_file.is_fixed(reg)) [[likely]] {
240240
scratch.alloc_specific(reg);
241241
return;
@@ -334,7 +334,7 @@ template <typename Adaptor,
334334
void EncodeCompiler<Adaptor, Derived, BaseTy, Config>::
335335
scratch_check_fixed_backup(ScratchReg &scratch,
336336
FixedRegBackup &backup_reg,
337-
const bool is_ret_reg) noexcept {
337+
const bool is_ret_reg) {
338338
if (!backup_reg.scratch.has_reg()) [[likely]] {
339339
return;
340340
}

tpde-encodegen/src/x64/EncCompilerTemplate.hpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -55,40 +55,40 @@ struct EncodeCompiler {
5555
using ValuePart = typename CompilerX64::ValuePart;
5656
using GenericValuePart = typename CompilerX64::GenericValuePart;
5757
58-
[[nodiscard]] static std::optional<i32> encodeable_as_imm32_sext(GenericValuePart &gv) noexcept;
59-
[[nodiscard]] static std::optional<FeMem> encodeable_as_mem(GenericValuePart &gv, unsigned align) noexcept;
60-
[[nodiscard]] static std::optional<FeMem> encodeable_with(GenericValuePart &gv, FeMem other, bool addr32 = false) noexcept;
58+
[[nodiscard]] static std::optional<i32> encodeable_as_imm32_sext(GenericValuePart &gv);
59+
[[nodiscard]] static std::optional<FeMem> encodeable_as_mem(GenericValuePart &gv, unsigned align);
60+
[[nodiscard]] static std::optional<FeMem> encodeable_with(GenericValuePart &gv, FeMem other, bool addr32 = false);
6161
void try_salvage_or_materialize(GenericValuePart &gv,
6262
ScratchReg &dst_scratch,
6363
u8 bank,
64-
u32 size) noexcept;
64+
u32 size);
6565
void try_salvage_or_materialize(GenericValuePart &gv,
6666
ValuePart &dst_scratch,
6767
u8 bank,
68-
u32 size) noexcept;
68+
u32 size);
6969
70-
CompilerX64 *derived() noexcept {
70+
CompilerX64 *derived() {
7171
return static_cast<CompilerX64 *>(static_cast<Derived *>(this));
7272
}
7373
74-
const CompilerX64 *derived() const noexcept {
74+
const CompilerX64 *derived() const {
7575
return static_cast<const CompilerX64 *>(
7676
static_cast<const Derived *>(this));
7777
}
7878
79-
static bool reg_needs_avx512(AsmReg reg) noexcept {
79+
static bool reg_needs_avx512(AsmReg reg) {
8080
if (reg.id() > AsmReg::XMM15) {
8181
return true;
8282
}
8383
return false;
8484
}
8585
86-
[[nodiscard]] bool has_avx() const noexcept {
86+
[[nodiscard]] bool has_avx() const {
8787
return derived()->has_cpu_feats(CompilerX64::CPU_AVX);
8888
}
8989
9090
[[nodiscard]] static bool disp_add_encodeable(int32_t disp,
91-
int32_t add) noexcept {
91+
int32_t add) {
9292
const auto tmp = static_cast<int64_t>(disp) + add;
9393
return (static_cast<int64_t>(static_cast<int32_t>(tmp)) == tmp);
9494
}
@@ -103,13 +103,13 @@ struct EncodeCompiler {
103103
void scratch_alloc_specific(AsmReg reg,
104104
ScratchReg &scratch,
105105
std::initializer_list<GenericValuePart *> operands,
106-
FixedRegBackup &backup_reg) noexcept;
106+
FixedRegBackup &backup_reg);
107107
108108
void scratch_check_fixed_backup(ScratchReg &scratch,
109109
FixedRegBackup &backup_reg,
110-
bool is_ret_reg) noexcept;
110+
bool is_ret_reg);
111111
112-
void reset() noexcept {
112+
void reset() {
113113
symbols.fill({});
114114
}
115115
@@ -135,7 +135,7 @@ template <typename Adaptor,
135135
class BaseTy,
136136
typename Config>
137137
std::optional<i32> EncodeCompiler<Adaptor, Derived, BaseTy, Config>::
138-
encodeable_as_imm32_sext(GenericValuePart &gv) noexcept {
138+
encodeable_as_imm32_sext(GenericValuePart &gv) {
139139
if (!gv.is_imm()) {
140140
return std::nullopt;
141141
}
@@ -155,7 +155,7 @@ template <typename Adaptor,
155155
class BaseTy,
156156
typename Config>
157157
std::optional<FeMem> EncodeCompiler<Adaptor, Derived, BaseTy, Config>::
158-
encodeable_as_mem(GenericValuePart &gv, unsigned align) noexcept {
158+
encodeable_as_mem(GenericValuePart &gv, unsigned align) {
159159
if (!std::holds_alternative<ValuePartRef>(gv.state)) {
160160
return std::nullopt;
161161
}
@@ -179,7 +179,7 @@ template <typename Adaptor,
179179
class BaseTy,
180180
typename Config>
181181
std::optional<FeMem> EncodeCompiler<Adaptor, Derived, BaseTy, Config>::
182-
encodeable_with(GenericValuePart &gv, FeMem other, bool addr32) noexcept {
182+
encodeable_with(GenericValuePart &gv, FeMem other, bool addr32) {
183183
const auto disp_encodeable = [addr32](u64 a, u64 b) -> std::optional<i32> {
184184
auto sum = static_cast<i32>(a + b);
185185
if (addr32 || static_cast<i64>(sum) == static_cast<i64>(a + b))
@@ -240,7 +240,7 @@ void EncodeCompiler<Adaptor, Derived, BaseTy, Config>::
240240
try_salvage_or_materialize(GenericValuePart &gv,
241241
ScratchReg &dst_scratch,
242242
u8 bank,
243-
u32 size) noexcept {
243+
u32 size) {
244244
AsmReg reg = derived()->gval_as_reg_reuse(gv, dst_scratch);
245245
if (!dst_scratch.has_reg()) {
246246
dst_scratch.alloc(RegBank(bank));
@@ -259,7 +259,7 @@ void EncodeCompiler<Adaptor, Derived, BaseTy, Config>::
259259
try_salvage_or_materialize(GenericValuePart &gv,
260260
ValuePart &dst_scratch,
261261
u8 ,
262-
u32 size) noexcept {
262+
u32 size) {
263263
AsmReg reg = derived()->gval_as_reg_reuse(gv, dst_scratch);
264264
if (!dst_scratch.has_reg()) {
265265
dst_scratch.alloc_reg(derived());
@@ -278,7 +278,7 @@ void EncodeCompiler<Adaptor, Derived, BaseTy, Config>::scratch_alloc_specific(
278278
AsmReg reg,
279279
ScratchReg &scratch,
280280
std::initializer_list<GenericValuePart *> operands,
281-
FixedRegBackup &backup_reg) noexcept {
281+
FixedRegBackup &backup_reg) {
282282
if (!derived()->register_file.is_fixed(reg)) [[likely]] {
283283
scratch.alloc_specific(reg);
284284
return;
@@ -389,7 +389,7 @@ template <typename Adaptor,
389389
void EncodeCompiler<Adaptor, Derived, BaseTy, Config>::
390390
scratch_check_fixed_backup(ScratchReg &scratch,
391391
FixedRegBackup &backup_reg,
392-
const bool is_ret_reg) noexcept {
392+
const bool is_ret_reg) {
393393
if (!backup_reg.scratch.has_reg()) [[likely]] {
394394
return;
395395
}

tpde-llvm/include/tpde-llvm/LLVMCompiler.hpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,21 @@ class JITMapper {
2727
std::unique_ptr<JITMapperImpl> impl;
2828

2929
public:
30-
explicit JITMapper(std::unique_ptr<JITMapperImpl> impl) noexcept;
30+
explicit JITMapper(std::unique_ptr<JITMapperImpl> impl);
3131
~JITMapper();
3232

3333
JITMapper(const JITMapper &) = delete;
34-
JITMapper(JITMapper &&other) noexcept;
34+
JITMapper(JITMapper &&other);
3535

3636
JITMapper &operator=(const JITMapper &) = delete;
37-
JITMapper &operator=(JITMapper &&other) noexcept;
37+
JITMapper &operator=(JITMapper &&other);
3838

3939
/// Get the address for a global, which must be contained in the compiled
4040
/// module.
41-
void *lookup_global(llvm::GlobalValue *) noexcept;
41+
void *lookup_global(llvm::GlobalValue *);
4242

4343
/// Indicate whether compilation and in-memory mapping was successful.
44-
operator bool() const noexcept { return impl != nullptr; }
44+
operator bool() const { return impl != nullptr; }
4545
};
4646

4747
/// Compiler for LLVM modules
@@ -58,21 +58,19 @@ class LLVMCompiler {
5858
/// Create a compiler for the specified target triple; returns null if the
5959
/// triple is not supported. The only supported code model is small, the only
6060
/// supported relocation model is PIC.
61-
static std::unique_ptr<LLVMCompiler>
62-
create(const llvm::Triple &triple) noexcept;
61+
static std::unique_ptr<LLVMCompiler> create(const llvm::Triple &triple);
6362

6463
/// Compile the module to an object file and emit it into the buffer. The
6564
/// module might be modified during compilation.
6665
/// \returns true on success.
67-
virtual bool compile_to_elf(llvm::Module &mod,
68-
std::vector<uint8_t> &buf) noexcept = 0;
66+
virtual bool compile_to_elf(llvm::Module &mod, std::vector<uint8_t> &buf) = 0;
6967

7068
/// Compile the module and map it into memory, calling resolver to resolve
7169
/// references to external symbols. This function will also register unwind
7270
/// information. The module might be modified during compilation.
73-
virtual JITMapper compile_and_map(
74-
llvm::Module &mod,
75-
std::function<void *(std::string_view)> resolver) noexcept = 0;
71+
virtual JITMapper
72+
compile_and_map(llvm::Module &mod,
73+
std::function<void *(std::string_view)> resolver) = 0;
7674
};
7775

7876
} // namespace tpde_llvm

tpde-llvm/src/JITMapper.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,21 @@
1111

1212
namespace tpde_llvm {
1313

14-
bool JITMapperImpl::map(
15-
tpde::elf::AssemblerElf &assembler,
16-
tpde::elf::ElfMapper::SymbolResolver resolver) noexcept {
14+
bool JITMapperImpl::map(tpde::elf::AssemblerElf &assembler,
15+
tpde::elf::ElfMapper::SymbolResolver resolver) {
1716
llvm::TimeTraceScope time_scope("TPDE_JITMap");
1817
return mapper.map(assembler, resolver);
1918
}
2019

21-
JITMapper::JITMapper(std::unique_ptr<JITMapperImpl> impl) noexcept
20+
JITMapper::JITMapper(std::unique_ptr<JITMapperImpl> impl)
2221
: impl(std::move(impl)) {}
2322

2423
JITMapper::~JITMapper() = default;
2524

26-
JITMapper::JITMapper(JITMapper &&other) noexcept = default;
27-
JITMapper &JITMapper::operator=(JITMapper &&other) noexcept = default;
25+
JITMapper::JITMapper(JITMapper &&other) = default;
26+
JITMapper &JITMapper::operator=(JITMapper &&other) = default;
2827

29-
void *JITMapper::lookup_global(llvm::GlobalValue *gv) noexcept {
28+
void *JITMapper::lookup_global(llvm::GlobalValue *gv) {
3029
return impl ? impl->lookup_global(gv) : nullptr;
3130
}
3231

tpde-llvm/src/JITMapper.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@ class JITMapperImpl {
2121
JITMapperImpl(GlobalMap &&globals) : globals(std::move(globals)) {}
2222

2323
/// Map the ELF from the assembler into memory, returns true on success.
24-
bool map(tpde::elf::AssemblerElf &,
25-
tpde::elf::ElfMapper::SymbolResolver) noexcept;
24+
bool map(tpde::elf::AssemblerElf &, tpde::elf::ElfMapper::SymbolResolver);
2625

27-
void *lookup_global(llvm::GlobalValue *gv) noexcept {
26+
void *lookup_global(llvm::GlobalValue *gv) {
2827
return mapper.get_sym_addr(globals.lookup(gv));
2928
}
3029
};

0 commit comments

Comments
 (0)