Skip to content

Commit 7512767

Browse files
authored
Merge pull request #10074 from swiftlang/egorzhdan/20240723-workaround-gvn
🍒[cxx-interop] Workaround a template instantiation issue
2 parents 4ed5ffd + 30908aa commit 7512767

File tree

2 files changed

+29
-29
lines changed
  • llvm
    • include/llvm/Transforms/Scalar
    • lib/Transforms/Scalar

2 files changed

+29
-29
lines changed

llvm/include/llvm/Transforms/Scalar/GVN.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,4 +403,33 @@ struct GVNSinkPass : PassInfoMixin<GVNSinkPass> {
403403

404404
} // end namespace llvm
405405

406+
struct llvm::GVNPass::Expression {
407+
uint32_t opcode;
408+
bool commutative = false;
409+
// The type is not necessarily the result type of the expression, it may be
410+
// any additional type needed to disambiguate the expression.
411+
Type *type = nullptr;
412+
SmallVector<uint32_t, 4> varargs;
413+
414+
Expression(uint32_t o = ~2U) : opcode(o) {}
415+
416+
bool operator==(const Expression &other) const {
417+
if (opcode != other.opcode)
418+
return false;
419+
if (opcode == ~0U || opcode == ~1U)
420+
return true;
421+
if (type != other.type)
422+
return false;
423+
if (varargs != other.varargs)
424+
return false;
425+
return true;
426+
}
427+
428+
friend hash_code hash_value(const Expression &Value) {
429+
return hash_combine(
430+
Value.opcode, Value.type,
431+
hash_combine_range(Value.varargs.begin(), Value.varargs.end()));
432+
}
433+
};
434+
406435
#endif // LLVM_TRANSFORMS_SCALAR_GVN_H

llvm/lib/Transforms/Scalar/GVN.cpp

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -135,35 +135,6 @@ static cl::opt<uint32_t> MaxNumInsnsPerBlock(
135135
cl::desc("Max number of instructions to scan in each basic block in GVN "
136136
"(default = 100)"));
137137

138-
struct llvm::GVNPass::Expression {
139-
uint32_t opcode;
140-
bool commutative = false;
141-
// The type is not necessarily the result type of the expression, it may be
142-
// any additional type needed to disambiguate the expression.
143-
Type *type = nullptr;
144-
SmallVector<uint32_t, 4> varargs;
145-
146-
Expression(uint32_t o = ~2U) : opcode(o) {}
147-
148-
bool operator==(const Expression &other) const {
149-
if (opcode != other.opcode)
150-
return false;
151-
if (opcode == ~0U || opcode == ~1U)
152-
return true;
153-
if (type != other.type)
154-
return false;
155-
if (varargs != other.varargs)
156-
return false;
157-
return true;
158-
}
159-
160-
friend hash_code hash_value(const Expression &Value) {
161-
return hash_combine(
162-
Value.opcode, Value.type,
163-
hash_combine_range(Value.varargs.begin(), Value.varargs.end()));
164-
}
165-
};
166-
167138
namespace llvm {
168139

169140
template <> struct DenseMapInfo<GVNPass::Expression> {

0 commit comments

Comments
 (0)