Skip to content

Commit 9829445

Browse files
committed
Revert "[InstCombine][DebugInfo] Fold constants wrapped in metadata"
This reverts commit b54a8ec. The commit triggered debug invariance (different output with/without -g). The patch seems to have exposed a pre-existing invariance problem in GlobalOpt, which I'll write a bug report for.
1 parent 3606f79 commit 9829445

File tree

2 files changed

+3
-76
lines changed

2 files changed

+3
-76
lines changed

llvm/lib/Transforms/InstCombine/InstructionCombining.cpp

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3620,20 +3620,10 @@ static bool AddReachableCodeToWorklist(BasicBlock *BB, const DataLayout &DL,
36203620

36213621
// See if we can constant fold its operands.
36223622
for (Use &U : Inst->operands()) {
3623-
bool WrapAsMetadata = false;
3624-
auto *V = cast<Value>(U);
3625-
3626-
// Look through metadata wrappers.
3627-
if (auto *MAV = dyn_cast<MetadataAsValue>(V))
3628-
if (auto *VAM = dyn_cast<ValueAsMetadata>(MAV->getMetadata())) {
3629-
V = VAM->getValue();
3630-
WrapAsMetadata = true;
3631-
}
3632-
3633-
if (!isa<ConstantVector>(V) && !isa<ConstantExpr>(V))
3623+
if (!isa<ConstantVector>(U) && !isa<ConstantExpr>(U))
36343624
continue;
36353625

3636-
auto *C = cast<Constant>(V);
3626+
auto *C = cast<Constant>(U);
36373627
Constant *&FoldRes = FoldedConstants[C];
36383628
if (!FoldRes)
36393629
FoldRes = ConstantFoldConstant(C, DL, TLI);
@@ -3644,11 +3634,7 @@ static bool AddReachableCodeToWorklist(BasicBlock *BB, const DataLayout &DL,
36443634
LLVM_DEBUG(dbgs() << "IC: ConstFold operand of: " << *Inst
36453635
<< "\n Old = " << *C
36463636
<< "\n New = " << *FoldRes << '\n');
3647-
if (WrapAsMetadata)
3648-
U = MetadataAsValue::get(Inst->getContext(),
3649-
ValueAsMetadata::get(FoldRes));
3650-
else
3651-
U = FoldRes;
3637+
U = FoldRes;
36523638
MadeIRChange = true;
36533639
}
36543640
}

llvm/test/Transforms/InstCombine/constant-fold-metadata-wrapped.ll

Lines changed: 0 additions & 59 deletions
This file was deleted.

0 commit comments

Comments
 (0)