diff options
| author | Krzysztof Parzyszek <kparzysz@quicinc.com> | 2019-02-21 19:42:39 +0000 |
|---|---|---|
| committer | Krzysztof Parzyszek <kparzysz@quicinc.com> | 2019-02-21 19:42:39 +0000 |
| commit | f6e875bacfca6f767d38c245dfbbb6e68c5c1f26 (patch) | |
| tree | 2e547b84d4abf398d7226aa274557214199b5465 /llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp | |
| parent | 0ee7bd4ac5862ed18ba41faa5d67160734d4b493 (diff) | |
| download | bcm5719-llvm-f6e875bacfca6f767d38c245dfbbb6e68c5c1f26.tar.gz bcm5719-llvm-f6e875bacfca6f767d38c245dfbbb6e68c5c1f26.zip | |
[Hexagon] Use misaligned load instead of trap0(#0) for __builtin_trap
The trap instruction is intercepted by various runtime environments,
and instead of a crash it creates confusion.
This reapplies r354606 with a fix.
llvm-svn: 354611
Diffstat (limited to 'llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp')
| -rw-r--r-- | llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp b/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp index b0b029682bf..3ecb1428213 100644 --- a/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp +++ b/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp @@ -1313,6 +1313,38 @@ bool HexagonInstrInfo::expandPostRAPseudo(MachineInstr &MI) const { return true; } + case Hexagon::PS_crash: { + // Generate a misaligned load that is guaranteed to cause a crash. + class CrashPseudoSourceValue : public PseudoSourceValue { + public: + CrashPseudoSourceValue(const TargetInstrInfo &TII) + : PseudoSourceValue(TargetCustom, TII) {} + + bool isConstant(const MachineFrameInfo *) const override { + return false; + } + bool isAliased(const MachineFrameInfo *) const override { + return false; + } + bool mayAlias(const MachineFrameInfo *) const override { + return false; + } + void printCustom(raw_ostream &OS) const override { + OS << "MisalignedCrash"; + } + }; + + static const CrashPseudoSourceValue CrashPSV(*this); + MachineMemOperand *MMO = MF.getMachineMemOperand( + MachinePointerInfo(&CrashPSV), + MachineMemOperand::MOLoad | MachineMemOperand::MOVolatile, 8, 1); + BuildMI(MBB, MI, DL, get(Hexagon::PS_loadrdabs), Hexagon::D13) + .addImm(0xBADC0FEE) // Misaligned load. + .addMemOperand(MMO); + MBB.erase(MI); + return true; + } + case Hexagon::PS_tailcall_i: MI.setDesc(get(Hexagon::J2_jump)); return true; |

