}
/// Named ctor: The value can just be used without any preparation.
- static ForwardingAction triviallyForwardable(bool IsProfitable) {
+ static ForwardingAction triviallyForwardable(bool IsProfitable, Value *Val) {
ForwardingAction Result;
Result.Decision =
IsProfitable ? FD_CanForwardProfitably : FD_CanForwardLeaf;
- Result.Execute = []() { return true; };
+ Result.Execute = [=]() {
+ LLVM_DEBUG(dbgs() << " trivially forwarded: " << *Val << "\n");
+ return true;
+ };
return Result;
}
Access = TargetStmt->ensureValueRead(Inst);
Access->setNewAccessRelation(SameVal);
+ LLVM_DEBUG(dbgs() << " forwarded known content of " << *Inst
+ << " which is " << SameVal << "\n");
TotalReloads++;
NumReloads++;
return false;
// operands. This ensures that its operands are inserted before the
// instruction using them.
TargetStmt->prependInstruction(UseInst);
+
+ LLVM_DEBUG(dbgs() << " forwarded speculable instruction: " << *UseInst
+ << "\n");
NumInstructionsCopied++;
TotalInstructionsCopied++;
return true;
case VirtualUse::Block:
case VirtualUse::Hoisted:
// These can be used anywhere without special considerations.
- return ForwardingAction::triviallyForwardable(false);
+ return ForwardingAction::triviallyForwardable(false, UseVal);
case VirtualUse::Synthesizable: {
// Check if the value is synthesizable at the new location as well. This
VirtualUse TargetUse = VirtualUse::create(
S, TargetStmt, TargetStmt->getSurroundingLoop(), UseVal, true);
if (TargetUse.getKind() == VirtualUse::Synthesizable)
- return ForwardingAction::triviallyForwardable(false);
+ return ForwardingAction::triviallyForwardable(false, UseVal);
LLVM_DEBUG(
dbgs() << " Synthesizable would not be synthesizable anymore: "
}
case VirtualUse::ReadOnly: {
+ if (!ModelReadOnlyScalars)
+ return ForwardingAction::triviallyForwardable(false, UseVal);
+
// If we model read-only scalars, we need to create a MemoryAccess for it.
auto ExecAction = [this, TargetStmt, UseVal]() {
- if (ModelReadOnlyScalars)
- TargetStmt->ensureValueRead(UseVal);
+ TargetStmt->ensureValueRead(UseVal);
+ LLVM_DEBUG(dbgs() << " forwarded read-only value " << *UseVal
+ << "\n");
NumReadOnlyCopied++;
TotalReadOnlyCopied++;