[PATCH] D73301: [PatchableFunction] Allow empty entry MachineBasicBlock
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 23 15:32:34 PST 2020
MaskRay created this revision.
MaskRay added reviewers: nickdesaulniers, peter.smith.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
It is difficult to construct an IR test which will lower to an empty entry
MBB.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D73301
Files:
llvm/lib/CodeGen/PatchableFunction.cpp
Index: llvm/lib/CodeGen/PatchableFunction.cpp
===================================================================
--- llvm/lib/CodeGen/PatchableFunction.cpp
+++ llvm/lib/CodeGen/PatchableFunction.cpp
@@ -57,10 +57,15 @@
bool PatchableFunction::runOnMachineFunction(MachineFunction &MF) {
if (MF.getFunction().hasFnAttribute("patchable-function-entry")) {
MachineBasicBlock &FirstMBB = *MF.begin();
- MachineInstr &FirstMI = *FirstMBB.begin();
const TargetInstrInfo *TII = MF.getSubtarget().getInstrInfo();
- BuildMI(FirstMBB, FirstMI, FirstMI.getDebugLoc(),
- TII->get(TargetOpcode::PATCHABLE_FUNCTION_ENTER));
+ if (FirstMBB.empty()) {
+ BuildMI(&FirstMBB, DebugLoc(),
+ TII->get(TargetOpcode::PATCHABLE_FUNCTION_ENTER));
+ } else {
+ MachineInstr &FirstMI = *FirstMBB.begin();
+ BuildMI(FirstMBB, FirstMI, FirstMI.getDebugLoc(),
+ TII->get(TargetOpcode::PATCHABLE_FUNCTION_ENTER));
+ }
return true;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73301.240030.patch
Type: text/x-patch
Size: 994 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200123/1d4afed4/attachment.bin>
More information about the llvm-commits
mailing list