[PATCH] D81403: [IndirectThunks] Make generated MF structure as expected by all instruction selectors.
Kristof Beyls via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 17 23:11:51 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG832cfc767246: [IndirectThunks] Make generated MF structure as expected by all instruction… (authored by kristof.beyls).
Changed prior to commit:
https://reviews.llvm.org/D81403?vs=270195&id=271582#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D81403/new/
https://reviews.llvm.org/D81403
Files:
llvm/include/llvm/CodeGen/IndirectThunks.h
llvm/lib/Target/AArch64/AArch64SLSHardening.cpp
llvm/lib/Target/X86/X86IndirectThunks.cpp
llvm/test/CodeGen/AArch64/speculation-hardening-sls.ll
Index: llvm/test/CodeGen/AArch64/speculation-hardening-sls.ll
===================================================================
--- llvm/test/CodeGen/AArch64/speculation-hardening-sls.ll
+++ llvm/test/CodeGen/AArch64/speculation-hardening-sls.ll
@@ -1,7 +1,8 @@
; RUN: llc -mattr=harden-sls-retbr,harden-sls-blr -verify-machineinstrs -mtriple=aarch64-none-linux-gnu < %s | FileCheck %s --check-prefixes=CHECK,HARDEN,ISBDSB,ISBDSBDAGISEL
; RUN: llc -mattr=harden-sls-retbr,harden-sls-blr -mattr=+sb -verify-machineinstrs -mtriple=aarch64-none-linux-gnu < %s | FileCheck %s --check-prefixes=CHECK,HARDEN,SB,SBDAGISEL
; RUN: llc -verify-machineinstrs -mtriple=aarch64-none-linux-gnu < %s | FileCheck %s --check-prefixes=CHECK,NOHARDEN
-
+; RUN: llc -global-isel -global-isel-abort=0 -mattr=harden-sls-retbr,harden-sls-blr -verify-machineinstrs -mtriple=aarch64-none-linux-gnu < %s | FileCheck %s --check-prefixes=CHECK,HARDEN,ISBDSB
+; RUN: llc -global-isel -global-isel-abort=0 -mattr=harden-sls-retbr,harden-sls-blr -mattr=+sb -verify-machineinstrs -mtriple=aarch64-none-linux-gnu < %s | FileCheck %s --check-prefixes=CHECK,HARDEN,SB
; Function Attrs: norecurse nounwind readnone
define dso_local i32 @double_return(i32 %a, i32 %b) local_unnamed_addr {
Index: llvm/lib/Target/X86/X86IndirectThunks.cpp
===================================================================
--- llvm/lib/Target/X86/X86IndirectThunks.cpp
+++ llvm/lib/Target/X86/X86IndirectThunks.cpp
@@ -79,12 +79,9 @@
createThunkFunction(MMI, R11LVIThunkName);
}
void populateThunk(MachineFunction &MF) {
- // Grab the entry MBB and erase any other blocks. O0 codegen appears to
- // generate two bbs for the entry block.
+ assert (MF.size() == 1);
MachineBasicBlock *Entry = &MF.front();
Entry->clear();
- while (MF.size() > 1)
- MF.erase(std::next(MF.begin()));
// This code mitigates LVI by replacing each indirect call/jump with a
// direct call/jump to a thunk that looks like:
@@ -209,12 +206,9 @@
}
const TargetInstrInfo *TII = MF.getSubtarget<X86Subtarget>().getInstrInfo();
- // Grab the entry MBB and erase any other blocks. O0 codegen appears to
- // generate two bbs for the entry block.
+ assert (MF.size() == 1);
MachineBasicBlock *Entry = &MF.front();
Entry->clear();
- while (MF.size() > 1)
- MF.erase(std::next(MF.begin()));
MachineBasicBlock *CaptureSpec =
MF.CreateMachineBasicBlock(Entry->getBasicBlock());
Index: llvm/lib/Target/AArch64/AArch64SLSHardening.cpp
===================================================================
--- llvm/lib/Target/AArch64/AArch64SLSHardening.cpp
+++ llvm/lib/Target/AArch64/AArch64SLSHardening.cpp
@@ -214,12 +214,9 @@
const TargetInstrInfo *TII =
MF.getSubtarget<AArch64Subtarget>().getInstrInfo();
- // Grab the entry MBB and erase any other blocks. O0 codegen appears to
- // generate two bbs for the entry block.
+ assert (MF.size() == 1);
MachineBasicBlock *Entry = &MF.front();
Entry->clear();
- while (MF.size() > 1)
- MF.erase(std::next(MF.begin()));
// These thunks need to consist of the following instructions:
// __llvm_slsblr_thunk_xN:
Index: llvm/include/llvm/CodeGen/IndirectThunks.h
===================================================================
--- llvm/include/llvm/CodeGen/IndirectThunks.h
+++ llvm/include/llvm/CodeGen/IndirectThunks.h
@@ -69,10 +69,11 @@
// IR-level constructs we already made. Create them and insert them into the
// module.
MachineFunction &MF = MMI.getOrCreateMachineFunction(*F);
- MachineBasicBlock *EntryMBB = MF.CreateMachineBasicBlock(Entry);
+ // A MachineBasicBlock must not be created for the Entry block; code
+ // generation from an empty naked function in C source code also does not
+ // generate one. At least GlobalISel asserts if this invariant isn't
+ // respected.
- // Insert EntryMBB into MF. It's not in the module until we do this.
- MF.insert(MF.end(), EntryMBB);
// Set MF properties. We never use vregs...
MF.getProperties().set(MachineFunctionProperties::Property::NoVRegs);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81403.271582.patch
Type: text/x-patch
Size: 4119 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200618/0a04d394/attachment.bin>
More information about the llvm-commits
mailing list