Changeset View
Changeset View
Standalone View
Standalone View
llvm/lib/Transforms/Utils/Local.cpp
Show First 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
} | } | ||||
/// Wrap \p V in a ValueAsMetadata instance. | /// Wrap \p V in a ValueAsMetadata instance. | ||||
static MetadataAsValue *wrapValueInMetadata(LLVMContext &C, Value *V) { | static MetadataAsValue *wrapValueInMetadata(LLVMContext &C, Value *V) { | ||||
return MetadataAsValue::get(C, ValueAsMetadata::get(V)); | return MetadataAsValue::get(C, ValueAsMetadata::get(V)); | ||||
} | } | ||||
bool llvm::salvageDebugInfo(Instruction &I) { | static bool attemptToSalvageDebugInfo(Instruction &I) { | ||||
Orlando: Is there any value in returning a result at all (i.e. is the return value used anywhere?). | |||||
SmallVector<DbgVariableIntrinsic *, 1> DbgUsers; | SmallVector<DbgVariableIntrinsic *, 1> DbgUsers; | ||||
findDbgUsers(DbgUsers, &I); | findDbgUsers(DbgUsers, &I); | ||||
if (DbgUsers.empty()) | if (DbgUsers.empty()) | ||||
return false; | return false; | ||||
return salvageDebugInfoForDbgValues(I, DbgUsers); | return salvageDebugInfoForDbgValues(I, DbgUsers); | ||||
} | } | ||||
void llvm::salvageDebugInfoOrMarkUndef(Instruction &I) { | void llvm::salvageDebugInfo(Instruction &I) { | ||||
if (!salvageDebugInfo(I)) | if (!attemptToSalvageDebugInfo(I)) | ||||
replaceDbgUsesWithUndef(&I); | replaceDbgUsesWithUndef(&I); | ||||
} | } | ||||
bool llvm::salvageDebugInfoForDbgValues( | bool llvm::salvageDebugInfoForDbgValues( | ||||
Instruction &I, ArrayRef<DbgVariableIntrinsic *> DbgUsers) { | Instruction &I, ArrayRef<DbgVariableIntrinsic *> DbgUsers) { | ||||
auto &Ctx = I.getContext(); | auto &Ctx = I.getContext(); | ||||
auto wrapMD = [&](Value *V) { return wrapValueInMetadata(Ctx, V); }; | auto wrapMD = [&](Value *V) { return wrapValueInMetadata(Ctx, V); }; | ||||
▲ Show 20 Lines • Show All 167 Lines • ▼ Show 20 Lines | |||||
DII->setOperand(0, wrapValueInMetadata(Ctx, &To)); | DII->setOperand(0, wrapValueInMetadata(Ctx, &To)); | ||||
DII->setOperand(2, MetadataAsValue::get(Ctx, *DVR)); | DII->setOperand(2, MetadataAsValue::get(Ctx, *DVR)); | ||||
LLVM_DEBUG(dbgs() << "REWRITE: " << *DII << '\n'); | LLVM_DEBUG(dbgs() << "REWRITE: " << *DII << '\n'); | ||||
Changed = true; | Changed = true; | ||||
} | } | ||||
if (!UndefOrSalvage.empty()) { | if (!UndefOrSalvage.empty()) { | ||||
// Try to salvage the remaining debug users. | // Try to salvage the remaining debug users. | ||||
salvageDebugInfoOrMarkUndef(From); | salvageDebugInfo(From); | ||||
Changed = true; | Changed = true; | ||||
} | } | ||||
return Changed; | return Changed; | ||||
} | } | ||||
/// Check if a bitcast between a value of type \p FromTy to type \p ToTy would | /// Check if a bitcast between a value of type \p FromTy to type \p ToTy would | ||||
/// losslessly preserve the bits and semantics of the value. This predicate is | /// losslessly preserve the bits and semantics of the value. This predicate is | ||||
▲ Show 20 Lines • Show All 91 Lines • Show Last 20 Lines |
Is there any value in returning a result at all (i.e. is the return value used anywhere?).
IIRC the only reason the result of salvageDebugInfo was checked was to see if we need to replaceDbgUsesWithUndef (which is now done inside salvageDebugInfo.