aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff options
context:
space:
mode:
authorMarkus Böck <markus.boeck02@gmail.com>2022-07-06 12:27:44 +0200
committerMarkus Böck <markus.boeck02@gmail.com>2022-07-06 12:27:44 +0200
commit73440ca9f878f9c4150b339bdd56b234d9167ee9 (patch)
treefb25bfa1c8bc9321f5e014d5f944173d6482556c /llvm/lib/Bitcode/Reader/BitcodeReader.cpp
parent1ee533afd0a64d7e021eb2b5ad6aa1a7722023cf (diff)
downloadllvm-73440ca9f878f9c4150b339bdd56b234d9167ee9.zip
llvm-73440ca9f878f9c4150b339bdd56b234d9167ee9.tar.gz
llvm-73440ca9f878f9c4150b339bdd56b234d9167ee9.tar.bz2
[mlir] Define proper DenseMapInfo for Interfaces
Prior to this patch, using any kind of interface (op interface, attr interface, type interface) as the key of a llvm::DenseSet, llvm::DenseMap or other related containers, leads to invalid pointer dereferences, despite compiling. The gist of the problem is that a llvm::DenseMapInfo specialization for the base type (aka one of Operation*, Type or Attribute) are selected when using an interface as a key, which uses getFromOpaquePointer with invalid pointer addresses to construct instances for the empty key and tombstone key values. The interface is then constructed with this invalid base type and an attempt is made to lookup the implementation in the interface map, which then dereferences the invalid pointer address. (For more details and the exact call chain involved see the GitHub issue below) The current workaround is to use the more generic base type (eg. instead of DenseSet<FunctionOpInterface>, DenseSet<Operation*>), but this is strictly worse from a code perspective (doesn't enforce the invariant, code is less self documenting, having to insert casts etc). This patch fixes that issue by defining a DenseMapInfo specialization of Interface subclasses which uses a new constructor to construct an instance without querying a concept. That allows getEmptyKey and getTombstoneKey to construct an interface with invalid pointer values. Fixes https://github.com/llvm/llvm-project/issues/54908 Differential Revision: https://reviews.llvm.org/D129038
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
0 files changed, 0 insertions, 0 deletions