Remove compile time PreserveName switch based on NDEBUG
Summary: Following r263086, we are now relying on a flag on the Context to discard Value names in release builds. Reviewers: chandlerc Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D18024 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 263257
This commit is contained in:
parent
1e9c925182
commit
e803fc3276
|
@ -23,9 +23,7 @@ class CodeGenFunction;
|
||||||
/// \brief This is an IRBuilder insertion helper that forwards to
|
/// \brief This is an IRBuilder insertion helper that forwards to
|
||||||
/// CodeGenFunction::InsertHelper, which adds necessary metadata to
|
/// CodeGenFunction::InsertHelper, which adds necessary metadata to
|
||||||
/// instructions.
|
/// instructions.
|
||||||
template <bool PreserveNames>
|
class CGBuilderInserter : protected llvm::IRBuilderDefaultInserter {
|
||||||
class CGBuilderInserter
|
|
||||||
: protected llvm::IRBuilderDefaultInserter<PreserveNames> {
|
|
||||||
public:
|
public:
|
||||||
CGBuilderInserter() = default;
|
CGBuilderInserter() = default;
|
||||||
explicit CGBuilderInserter(CodeGenFunction *CGF) : CGF(CGF) {}
|
explicit CGBuilderInserter(CodeGenFunction *CGF) : CGF(CGF) {}
|
||||||
|
@ -39,17 +37,10 @@ private:
|
||||||
CodeGenFunction *CGF = nullptr;
|
CodeGenFunction *CGF = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Don't preserve names on values in an optimized build.
|
typedef CGBuilderInserter CGBuilderInserterTy;
|
||||||
#ifdef NDEBUG
|
|
||||||
#define PreserveNames false
|
|
||||||
#else
|
|
||||||
#define PreserveNames true
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef CGBuilderInserter<PreserveNames> CGBuilderInserterTy;
|
typedef llvm::IRBuilder<llvm::ConstantFolder, CGBuilderInserterTy>
|
||||||
|
CGBuilderBaseTy;
|
||||||
typedef llvm::IRBuilder<PreserveNames, llvm::ConstantFolder,
|
|
||||||
CGBuilderInserterTy> CGBuilderBaseTy;
|
|
||||||
|
|
||||||
class CGBuilderTy : public CGBuilderBaseTy {
|
class CGBuilderTy : public CGBuilderBaseTy {
|
||||||
/// Storing a reference to the type cache here makes it a lot easier
|
/// Storing a reference to the type cache here makes it a lot easier
|
||||||
|
@ -305,8 +296,6 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#undef PreserveNames
|
|
||||||
|
|
||||||
} // end namespace CodeGen
|
} // end namespace CodeGen
|
||||||
} // end namespace clang
|
} // end namespace clang
|
||||||
|
|
||||||
|
|
|
@ -3840,7 +3840,7 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::Instruction *CI = CS.getInstruction();
|
llvm::Instruction *CI = CS.getInstruction();
|
||||||
if (Builder.isNamePreserving() && !CI->getType()->isVoidTy())
|
if (!CI->getType()->isVoidTy())
|
||||||
CI->setName("call");
|
CI->setName("call");
|
||||||
|
|
||||||
// Emit any writebacks immediately. Arguably this should happen
|
// Emit any writebacks immediately. Arguably this should happen
|
||||||
|
|
|
@ -66,8 +66,6 @@ Address CodeGenFunction::CreateTempAlloca(llvm::Type *Ty, CharUnits Align,
|
||||||
/// block.
|
/// block.
|
||||||
llvm::AllocaInst *CodeGenFunction::CreateTempAlloca(llvm::Type *Ty,
|
llvm::AllocaInst *CodeGenFunction::CreateTempAlloca(llvm::Type *Ty,
|
||||||
const Twine &Name) {
|
const Twine &Name) {
|
||||||
if (!Builder.isNamePreserving())
|
|
||||||
return new llvm::AllocaInst(Ty, nullptr, "", AllocaInsertPt);
|
|
||||||
return new llvm::AllocaInst(Ty, nullptr, Name, AllocaInsertPt);
|
return new llvm::AllocaInst(Ty, nullptr, Name, AllocaInsertPt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -656,7 +656,13 @@ void BackendConsumer::DiagnosticHandlerImpl(const DiagnosticInfo &DI) {
|
||||||
|
|
||||||
CodeGenAction::CodeGenAction(unsigned _Act, LLVMContext *_VMContext)
|
CodeGenAction::CodeGenAction(unsigned _Act, LLVMContext *_VMContext)
|
||||||
: Act(_Act), VMContext(_VMContext ? _VMContext : new LLVMContext),
|
: Act(_Act), VMContext(_VMContext ? _VMContext : new LLVMContext),
|
||||||
OwnsVMContext(!_VMContext) {}
|
OwnsVMContext(!_VMContext) {
|
||||||
|
#ifdef NDEBUG
|
||||||
|
// FIXME: change this to be controlled by a cc1 flag that the driver passes,
|
||||||
|
// on the model of --disable-free
|
||||||
|
_VMContext.setDiscardValueNames(true);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
CodeGenAction::~CodeGenAction() {
|
CodeGenAction::~CodeGenAction() {
|
||||||
TheModule.reset();
|
TheModule.reset();
|
||||||
|
|
|
@ -747,9 +747,7 @@ void CodeGenFunction::StartFunction(GlobalDecl GD,
|
||||||
// later. Don't create this with the builder, because we don't want it
|
// later. Don't create this with the builder, because we don't want it
|
||||||
// folded.
|
// folded.
|
||||||
llvm::Value *Undef = llvm::UndefValue::get(Int32Ty);
|
llvm::Value *Undef = llvm::UndefValue::get(Int32Ty);
|
||||||
AllocaInsertPt = new llvm::BitCastInst(Undef, Int32Ty, "", EntryBB);
|
AllocaInsertPt = new llvm::BitCastInst(Undef, Int32Ty, "allocapt", EntryBB);
|
||||||
if (Builder.isNamePreserving())
|
|
||||||
AllocaInsertPt->setName("allocapt");
|
|
||||||
|
|
||||||
ReturnBlock = getJumpDestInCurrentScope("return");
|
ReturnBlock = getJumpDestInCurrentScope("return");
|
||||||
|
|
||||||
|
@ -1862,26 +1860,14 @@ void CodeGenFunction::InsertHelper(llvm::Instruction *I,
|
||||||
CGM.getSanitizerMetadata()->disableSanitizerForInstruction(I);
|
CGM.getSanitizerMetadata()->disableSanitizerForInstruction(I);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <bool PreserveNames>
|
void CGBuilderInserter::InsertHelper(
|
||||||
void CGBuilderInserter<PreserveNames>::InsertHelper(
|
|
||||||
llvm::Instruction *I, const llvm::Twine &Name, llvm::BasicBlock *BB,
|
llvm::Instruction *I, const llvm::Twine &Name, llvm::BasicBlock *BB,
|
||||||
llvm::BasicBlock::iterator InsertPt) const {
|
llvm::BasicBlock::iterator InsertPt) const {
|
||||||
llvm::IRBuilderDefaultInserter<PreserveNames>::InsertHelper(I, Name, BB,
|
llvm::IRBuilderDefaultInserter::InsertHelper(I, Name, BB, InsertPt);
|
||||||
InsertPt);
|
|
||||||
if (CGF)
|
if (CGF)
|
||||||
CGF->InsertHelper(I, Name, BB, InsertPt);
|
CGF->InsertHelper(I, Name, BB, InsertPt);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef NDEBUG
|
|
||||||
#define PreserveNames false
|
|
||||||
#else
|
|
||||||
#define PreserveNames true
|
|
||||||
#endif
|
|
||||||
template void CGBuilderInserter<PreserveNames>::InsertHelper(
|
|
||||||
llvm::Instruction *I, const llvm::Twine &Name, llvm::BasicBlock *BB,
|
|
||||||
llvm::BasicBlock::iterator InsertPt) const;
|
|
||||||
#undef PreserveNames
|
|
||||||
|
|
||||||
static bool hasRequiredFeatures(const SmallVectorImpl<StringRef> &ReqFeatures,
|
static bool hasRequiredFeatures(const SmallVectorImpl<StringRef> &ReqFeatures,
|
||||||
CodeGenModule &CGM, const FunctionDecl *FD,
|
CodeGenModule &CGM, const FunctionDecl *FD,
|
||||||
std::string &FirstMissing) {
|
std::string &FirstMissing) {
|
||||||
|
|
Loading…
Reference in New Issue