[PATCH] D137642: [X86][CodeGen] Fix crash in hotpatch

Sylvain Audi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 8 06:56:12 PST 2022


saudi created this revision.
saudi added reviewers: amccarth, craig.topper, hans, rnk, thieta, aganea.
saudi added a project: LLVM.
Herald added subscribers: StephenFan, pengfei, hiraditya.
Herald added a project: All.
saudi requested review of this revision.
Herald added a subscriber: llvm-commits.

This patch fixes crashes (asserts) encountered in some cases while activating hotpatch using `-fms-hotpatch`, or `clang-cl /HOTPATCH`.

`PatchableFunction` pass emits a `TargetOpcode::PATCHABLE_OP` at the first LLVM-IR instruction that generates machine code. The search for that instruction was done with a local helper that hasn't been updated along with the addition of new LLVM-IR instructions.

Example crash: https://godbolt.org/z/8M9vGajs9
In this example, `DBG_INSTR_REF` is selected for `TargetOpcode::PATCHABLE_OP`; lowering that instruction asserts as the metadata-typed operands are unexpected.

Also, the search for the first instruction was assuming that one would be found, asserting otherwise. 
Such case may happen in the case of an empty function that is unreachable ( in C/C++, a simple example is `int f() {}` )


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137642

Files:
  llvm/lib/CodeGen/PatchableFunction.cpp
  llvm/test/CodeGen/X86/patchable-prologue-debuginfo.ll
  llvm/test/CodeGen/X86/patchable-prologue.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137642.473980.patch
Type: text/x-patch
Size: 5570 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221108/007769e8/attachment.bin>


More information about the llvm-commits mailing list