[llvm] eabf7ec - [GlobalISel] Fix misaligned read after #74429
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 13 14:05:10 PST 2023
Author: Vitaly Buka
Date: 2023-12-13T14:04:59-08:00
New Revision: eabf7ec3f3d4688ea0f9da24038462362837d7ff
URL: https://github.com/llvm/llvm-project/commit/eabf7ec3f3d4688ea0f9da24038462362837d7ff
DIFF: https://github.com/llvm/llvm-project/commit/eabf7ec3f3d4688ea0f9da24038462362837d7ff.diff
LOG: [GlobalISel] Fix misaligned read after #74429
Added:
Modified:
llvm/include/llvm/CodeGen/GlobalISel/GIMatchTableExecutor.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/CodeGen/GlobalISel/GIMatchTableExecutor.h b/llvm/include/llvm/CodeGen/GlobalISel/GIMatchTableExecutor.h
index 73308925e9142d..724f39634297a4 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/GIMatchTableExecutor.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/GIMatchTableExecutor.h
@@ -690,7 +690,9 @@ class GIMatchTableExecutor {
bool isObviouslySafeToFold(MachineInstr &MI, MachineInstr &IntoMI) const;
template <typename Ty> static Ty readBytesAs(const uint8_t *MatchTable) {
- return *reinterpret_cast<const Ty *>(MatchTable);
+ Ty res;
+ memcpy(&res, MatchTable, sizeof(res));
+ return res;
}
};
More information about the llvm-commits
mailing list