mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-03-01 16:31:13 +00:00
Fix for PR14739. It's not safe to fold a load into a call across a store. Thanks to Nick Lewycky for the initial patch.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171665 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c6b4936a59
commit
700843ec2c
@ -420,6 +420,11 @@ static bool isCalleeLoad(SDValue Callee, SDValue &Chain, bool HasCallSeq) {
|
|||||||
|
|
||||||
if (!Chain.getNumOperands())
|
if (!Chain.getNumOperands())
|
||||||
return false;
|
return false;
|
||||||
|
// Since we are not checking for AA here, conservatively abort if the chain
|
||||||
|
// writes to memory. It's not safe to move the callee (a load) across a store.
|
||||||
|
if (isa<MemSDNode>(Chain.getNode()) &&
|
||||||
|
cast<MemSDNode>(Chain.getNode())->writeMem())
|
||||||
|
return false;
|
||||||
if (Chain.getOperand(0).getNode() == Callee.getNode())
|
if (Chain.getOperand(0).getNode() == Callee.getNode())
|
||||||
return true;
|
return true;
|
||||||
if (Chain.getOperand(0).getOpcode() == ISD::TokenFactor &&
|
if (Chain.getOperand(0).getOpcode() == ISD::TokenFactor &&
|
||||||
|
@ -1,10 +1,27 @@
|
|||||||
; RUN: llc < %s -march=x86 | not grep mov
|
; RUN: llc < %s -march=x86 | FileCheck %s
|
||||||
; RUN: llc < %s -march=x86-64 | not grep mov
|
; RUN: llc < %s -march=x86-64 | FileCheck %s
|
||||||
|
|
||||||
|
; CHECK: test1
|
||||||
|
; CHECK-NOT: mov
|
||||||
|
|
||||||
declare void @bar()
|
declare void @bar()
|
||||||
|
define void @test1(i32 %i0, i32 %i1, i32 %i2, i32 %i3, i32 %i4, i32 %i5, void()* %arg) nounwind {
|
||||||
define void @foo(i32 %i0, i32 %i1, i32 %i2, i32 %i3, i32 %i4, i32 %i5, void()* %arg) nounwind {
|
|
||||||
call void @bar()
|
call void @bar()
|
||||||
call void %arg()
|
call void %arg()
|
||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
; PR14739
|
||||||
|
; CHECK: test2
|
||||||
|
; CHECK: mov{{.*}} $0, ([[REGISTER:%[a-z]+]])
|
||||||
|
; CHECK-NOT: jmp{{.*}} *([[REGISTER]])
|
||||||
|
|
||||||
|
%struct.X = type { void ()* }
|
||||||
|
define void @test2(%struct.X* nocapture %x) {
|
||||||
|
entry:
|
||||||
|
%f = getelementptr inbounds %struct.X* %x, i64 0, i32 0
|
||||||
|
%0 = load void ()** %f
|
||||||
|
store void ()* null, void ()** %f
|
||||||
|
tail call void %0()
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user