Skip to content

Commit e8ea8c0

Browse files
committed
fixup! [Pass, SCCP] Support constant structure in PhiNode
1 parent b3cc74c commit e8ea8c0

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

llvm/lib/Transforms/Utils/SCCPSolver.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ class SCCPInstVisitor : public InstVisitor<SCCPInstVisitor> {
761761
void handleCallArguments(CallBase &CB);
762762
void handleExtractOfWithOverflow(ExtractValueInst &EVI,
763763
const WithOverflowInst *WO, unsigned Idx);
764-
bool isInstUnderDefined(Instruction &Inst);
764+
bool isInstOverDefined(Instruction &Inst);
765765

766766
private:
767767
friend class InstVisitor<SCCPInstVisitor>;
@@ -1381,9 +1381,9 @@ void SCCPInstVisitor::visitPHINode(PHINode &PN) {
13811381
if (PN.getNumIncomingValues() > 64)
13821382
return (void)markOverdefined(&PN);
13831383

1384-
if (isInstUnderDefined(PN))
1384+
if (isInstOverDefined(PN))
13851385
return;
1386-
llvm::SmallVector<unsigned> FeasibleIncomingIndices;
1386+
SmallVector<unsigned> FeasibleIncomingIndices;
13871387
for (unsigned i = 0, e = PN.getNumIncomingValues(); i != e; ++i) {
13881388
if (!isEdgeFeasible(PN.getIncomingBlock(i), PN.getParent()))
13891389
continue;
@@ -2146,10 +2146,10 @@ void SCCPInstVisitor::handleCallResult(CallBase &CB) {
21462146
}
21472147
}
21482148

2149-
bool SCCPInstVisitor::isInstUnderDefined(Instruction &Inst) {
2150-
// For structure Type, we handle each member seperately.
2151-
// A structure object won't be considered as overDefined when
2152-
// there is at least one member can become constant.
2149+
bool SCCPInstVisitor::isInstOverDefined(Instruction &Inst) {
2150+
// For structure Type, we handle each member separately.
2151+
// A structure object won't be considered as overdefined when
2152+
// there is at least one member that is not overdefined.
21532153
if (StructType *STy = dyn_cast<StructType>(Inst.getType())) {
21542154
for (unsigned i = 0, e = STy->getNumElements(); i < e; ++i) {
21552155
if (!getStructValueState(&Inst, i).isOverdefined())

llvm/test/Transforms/SCCP/constant-range-struct.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ define void @struct2_caller() {
161161
%"phi_type" = type {i64, i64}
162162

163163
; Function Attrs: mustprogress
164-
define internal noundef %"phi_type" @test(i32 noundef %input) local_unnamed_addr readnone nounwind {
164+
define internal %"phi_type" @test(i32 %input) {
165165
; CHECK-LABEL: @test(
166166
; CHECK-NEXT: br label [[COND_TRUE_I:%.*]]
167167
; CHECK: cond.true.i:
@@ -187,7 +187,7 @@ cond.end.i:
187187
ret %"phi_type" %retval
188188
}
189189

190-
define dso_local noundef %"phi_type" @test2() {
190+
define %"phi_type" @test2() {
191191
; CHECK-LABEL: @test2(
192192
; CHECK-NEXT: [[CALL_1:%.*]] = tail call fastcc [[PHI_TYPE:%.*]] @[[TEST:[a-zA-Z0-9_$\"\\.-]*[a-zA-Z_$\"\\.-][a-zA-Z0-9_$\"\\.-]*]](i32 noundef 1)
193193
; CHECK-NEXT: ret [[PHI_TYPE]] { i64 1, i64 2 }

0 commit comments

Comments
 (0)