diff options
author | David Majnemer <david.majnemer@gmail.com> | 2016-08-09 17:55:12 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2016-08-09 17:55:12 +0000 |
commit | adc688ce9c2034a0fc5a094d61b76f356123a927 (patch) | |
tree | 3b72c5eb7860eb20c83eed31c555abef98681d59 | |
parent | 8c5314479ebbf2c70225b94641b464da81ef6f79 (diff) | |
download | bcm5719-llvm-adc688ce9c2034a0fc5a094d61b76f356123a927.tar.gz bcm5719-llvm-adc688ce9c2034a0fc5a094d61b76f356123a927.zip |
[X86] Don't model UD2/UD2B as a terminator
A UD2 might make its way into the program via a call to @llvm.trap.
Obviously, calls are not terminators. However, we modeled the X86
instruction, UD2, as a terminator. Later on, this confuses the epilogue
insertion machinery which results in the epilogue getting inserted
before the UD2. For some platforms, like x64, the result is a
violation of the ABI.
Instead, model UD2/UD2B as a side effecting instruction which may
observe memory.
llvm-svn: 278144
-rw-r--r-- | llvm/lib/Target/X86/X86InstrSystem.td | 2 | ||||
-rw-r--r-- | llvm/test/CodeGen/X86/x86-framelowering-trap.ll | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/Target/X86/X86InstrSystem.td b/llvm/lib/Target/X86/X86InstrSystem.td index 6667bd2aec4..97dc2af2c6c 100644 --- a/llvm/lib/Target/X86/X86InstrSystem.td +++ b/llvm/lib/Target/X86/X86InstrSystem.td @@ -23,7 +23,7 @@ let Defs = [RAX, RCX, RDX] in // CPU flow control instructions -let isTerminator = 1, isBarrier = 1, hasCtrlDep = 1 in { +let mayLoad = 1, mayStore = 0, hasSideEffects = 1 in { def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB; def UD2B : I<0xB9, RawFrm, (outs), (ins), "ud2b", []>, TB; } diff --git a/llvm/test/CodeGen/X86/x86-framelowering-trap.ll b/llvm/test/CodeGen/X86/x86-framelowering-trap.ll index 58a1da23a29..f1590abcae8 100644 --- a/llvm/test/CodeGen/X86/x86-framelowering-trap.ll +++ b/llvm/test/CodeGen/X86/x86-framelowering-trap.ll @@ -3,13 +3,18 @@ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" ; CHECK-LABEL: bar: +; CHECK: pushq ; CHECK: ud2 +; CHECK-NEXT: popq ; CHECK-NEXT: retq define void @bar() { entry: + call void @callee() call void @llvm.trap() ret void } ; Function Attrs: noreturn nounwind declare void @llvm.trap() + +declare void @callee() |