[llvm] 1b78860 - [X32][CET] Fix handling of indirect branches
Harald van Dijk via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 29 00:33:57 PDT 2021
Author: Harald van Dijk
Date: 2021-04-29T08:33:22+01:00
New Revision: 1b788607f549321ef1e8343554b432db07ba3fe6
URL: https://github.com/llvm/llvm-project/commit/1b788607f549321ef1e8343554b432db07ba3fe6
DIFF: https://github.com/llvm/llvm-project/commit/1b788607f549321ef1e8343554b432db07ba3fe6.diff
LOG: [X32][CET] Fix handling of indirect branches
As X32 uses 32-bit pointers without having 32-bit indirect branch
instructions, we need to fix up indirect branches by extending the
branch targets to 64 bits. This was already done for BRIND but not yet
for NT_BRIND. The same logic works for both, so this applies that
existing logic to NT_BRIND as well.
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D101499
Added:
Modified:
llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
llvm/test/CodeGen/X86/indirect-branch-tracking.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
index 8985041db948..73000781261e 100644
--- a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
+++ b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
@@ -4737,7 +4737,8 @@ void X86DAGToDAGISel::Select(SDNode *Node) {
}
break;
}
- case ISD::BRIND: {
+ case ISD::BRIND:
+ case X86ISD::NT_BRIND: {
if (Subtarget->isTargetNaCl())
// NaCl has its own pass where jmp %r32 are converted to jmp %r64. We
// leave the instruction alone.
@@ -4749,7 +4750,7 @@ void X86DAGToDAGISel::Select(SDNode *Node) {
SDValue Target = Node->getOperand(1);
assert(Target.getValueType() == MVT::i32 && "Unexpected VT!");
SDValue ZextTarget = CurDAG->getZExtOrTrunc(Target, dl, MVT::i64);
- SDValue Brind = CurDAG->getNode(ISD::BRIND, dl, MVT::Other,
+ SDValue Brind = CurDAG->getNode(Opcode, dl, MVT::Other,
Node->getOperand(0), ZextTarget);
ReplaceNode(Node, Brind.getNode());
SelectCode(ZextTarget.getNode());
diff --git a/llvm/test/CodeGen/X86/indirect-branch-tracking.ll b/llvm/test/CodeGen/X86/indirect-branch-tracking.ll
index dc738bb7b543..3992f3d00551 100644
--- a/llvm/test/CodeGen/X86/indirect-branch-tracking.ll
+++ b/llvm/test/CodeGen/X86/indirect-branch-tracking.ll
@@ -1,4 +1,5 @@
; RUN: llc -mtriple=x86_64-unknown-unknown < %s | FileCheck %s --check-prefix=ALL --check-prefix=X86_64
+; RUN: llc -mtriple=x86_64-unknown-unknown-gnux32 < %s | FileCheck %s --check-prefix=ALL --check-prefix=X86_64
; RUN: llc -mtriple=i386-unknown-unknown < %s | FileCheck %s --check-prefix=ALL --check-prefix=X86
; FIXME: Fix machine verifier issues and remove -verify-machineinstrs=0. PR39439.
; RUN: llc -mtriple i386-windows-gnu -exception-model sjlj -verify-machineinstrs=0 < %s | FileCheck %s --check-prefix=SJLJ
More information about the llvm-commits
mailing list