mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-15 22:28:18 +00:00
DeadArgElim: arguments affect all returned sub-values by default.
Unless we meet an insertvalue on a path from some value to a return, that value will be live if *any* of the return's components are live, so all of those components must be added to the MaybeLiveUses. Previously we were deleting arguments if sub-value 0 turned out to be dead. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228731 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -146,7 +146,7 @@ namespace {
|
|||||||
private:
|
private:
|
||||||
Liveness MarkIfNotLive(RetOrArg Use, UseVector &MaybeLiveUses);
|
Liveness MarkIfNotLive(RetOrArg Use, UseVector &MaybeLiveUses);
|
||||||
Liveness SurveyUse(const Use *U, UseVector &MaybeLiveUses,
|
Liveness SurveyUse(const Use *U, UseVector &MaybeLiveUses,
|
||||||
unsigned RetValNum = 0);
|
unsigned RetValNum = -1U);
|
||||||
Liveness SurveyUses(const Value *V, UseVector &MaybeLiveUses);
|
Liveness SurveyUses(const Value *V, UseVector &MaybeLiveUses);
|
||||||
|
|
||||||
void SurveyFunction(const Function &F);
|
void SurveyFunction(const Function &F);
|
||||||
@@ -443,9 +443,21 @@ DAE::Liveness DAE::SurveyUse(const Use *U,
|
|||||||
// function's return value is live. We use RetValNum here, for the case
|
// function's return value is live. We use RetValNum here, for the case
|
||||||
// that U is really a use of an insertvalue instruction that uses the
|
// that U is really a use of an insertvalue instruction that uses the
|
||||||
// original Use.
|
// original Use.
|
||||||
RetOrArg Use = CreateRet(RI->getParent()->getParent(), RetValNum);
|
const Function *F = RI->getParent()->getParent();
|
||||||
// We might be live, depending on the liveness of Use.
|
if (RetValNum != -1U) {
|
||||||
return MarkIfNotLive(Use, MaybeLiveUses);
|
RetOrArg Use = CreateRet(F, RetValNum);
|
||||||
|
// We might be live, depending on the liveness of Use.
|
||||||
|
return MarkIfNotLive(Use, MaybeLiveUses);
|
||||||
|
} else {
|
||||||
|
DAE::Liveness Result;
|
||||||
|
for (unsigned i = 0; i < NumRetVals(F); ++i) {
|
||||||
|
RetOrArg Use = CreateRet(F, i);
|
||||||
|
// We might be live, depending on the liveness of Use. All Results
|
||||||
|
// should be the same since they depend only on F.
|
||||||
|
Result = MarkIfNotLive(Use, MaybeLiveUses);
|
||||||
|
}
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (const InsertValueInst *IV = dyn_cast<InsertValueInst>(V)) {
|
if (const InsertValueInst *IV = dyn_cast<InsertValueInst>(V)) {
|
||||||
if (U->getOperandNo() != InsertValueInst::getAggregateOperandIndex()
|
if (U->getOperandNo() != InsertValueInst::getAggregateOperandIndex()
|
||||||
|
@@ -113,3 +113,20 @@ define void @test_can_shrink_arrays() {
|
|||||||
|
|
||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
; Case 5: %in gets passed directly to the return. It should mark be marked as
|
||||||
|
; used if *any* of the return values are, not just if value 0 is.
|
||||||
|
|
||||||
|
; CHECK-LABEL: define internal i32 @ret_applies_to_all({ i32, i32 } %in)
|
||||||
|
; CHECK: [[RET:%.*]] = extractvalue { i32, i32 } %in, 1
|
||||||
|
; CHECK: ret i32 [[RET]]
|
||||||
|
|
||||||
|
define internal {i32, i32} @ret_applies_to_all({i32, i32} %in) {
|
||||||
|
ret {i32, i32} %in
|
||||||
|
}
|
||||||
|
|
||||||
|
define i32 @test_ret_applies_to_all() {
|
||||||
|
%val = call {i32, i32} @ret_applies_to_all({i32, i32} {i32 42, i32 43})
|
||||||
|
%ret = extractvalue {i32, i32} %val, 1
|
||||||
|
ret i32 %ret
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user