[llvm] r212537 - Fix some Twine locals.
Benjamin Kramer
benny.kra at googlemail.com
Tue Jul 8 07:55:07 PDT 2014
Author: d0k
Date: Tue Jul 8 09:55:06 2014
New Revision: 212537
URL: http://llvm.org/viewvc/llvm-project?rev=212537&view=rev
Log:
Fix some Twine locals.
Two of those are use after frees. Found by clang-tidy, fixed by me.
Modified:
llvm/trunk/lib/CodeGen/GlobalMerge.cpp
llvm/trunk/lib/Support/Triple.cpp
llvm/trunk/lib/Transforms/Utils/LoopUnroll.cpp
Modified: llvm/trunk/lib/CodeGen/GlobalMerge.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalMerge.cpp?rev=212537&r1=212536&r2=212537&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalMerge.cpp (original)
+++ llvm/trunk/lib/CodeGen/GlobalMerge.cpp Tue Jul 8 09:55:06 2014
@@ -199,19 +199,17 @@ bool GlobalMerge::doMerge(SmallVectorImp
? GlobalValue::ExternalLinkage
: GlobalValue::InternalLinkage;
- // If merged variables have external linkage, we use symbol name of the
- // first variable merged as the suffix of global symbol name. This would
- // be able to avoid the link-time naming conflict for globalm symbols.
- Twine MergedGVName = HasExternal
- ? "_MergedGlobals_" + TheFirstExternal->getName()
- : "_MergedGlobals";
-
StructType *MergedTy = StructType::get(M.getContext(), Tys);
Constant *MergedInit = ConstantStruct::get(MergedTy, Inits);
+ // If merged variables have external linkage, we use symbol name of the
+ // first variable merged as the suffix of global symbol name. This would
+ // be able to avoid the link-time naming conflict for globalm symbols.
GlobalVariable *MergedGV = new GlobalVariable(
- M, MergedTy, isConst, Linkage, MergedInit, MergedGVName, nullptr,
- GlobalVariable::NotThreadLocal, AddrSpace);
+ M, MergedTy, isConst, Linkage, MergedInit,
+ HasExternal ? "_MergedGlobals_" + TheFirstExternal->getName()
+ : "_MergedGlobals",
+ nullptr, GlobalVariable::NotThreadLocal, AddrSpace);
for (size_t k = i; k < j; ++k) {
GlobalValue::LinkageTypes Linkage = Globals[k]->getLinkage();
Modified: llvm/trunk/lib/Support/Triple.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Triple.cpp?rev=212537&r1=212536&r2=212537&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Triple.cpp (original)
+++ llvm/trunk/lib/Support/Triple.cpp Tue Jul 8 09:55:06 2014
@@ -737,9 +737,8 @@ void Triple::setObjectFormat(ObjectForma
if (Environment == UnknownEnvironment)
return setEnvironmentName(getObjectFormatTypeName(Kind));
- Twine Env = getEnvironmentTypeName(Environment) + Twine("-") +
- getObjectFormatTypeName(Kind);
- setEnvironmentName(Env.str());
+ setEnvironmentName((getEnvironmentTypeName(Environment) + Twine("-") +
+ getObjectFormatTypeName(Kind)).str());
}
void Triple::setArchName(StringRef Str) {
Modified: llvm/trunk/lib/Transforms/Utils/LoopUnroll.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LoopUnroll.cpp?rev=212537&r1=212536&r2=212537&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/LoopUnroll.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/LoopUnroll.cpp Tue Jul 8 09:55:06 2014
@@ -242,21 +242,25 @@ bool llvm::UnrollLoop(Loop *L, unsigned
Twine("completely unrolled loop with ") +
Twine(TripCount) + " iterations");
} else {
+ auto EmitDiag = [&](const Twine &T) {
+ emitOptimizationRemark(Ctx, DEBUG_TYPE, *F, LoopLoc,
+ "unrolled loop by a factor of " + Twine(Count) +
+ T);
+ };
+
DEBUG(dbgs() << "UNROLLING loop %" << Header->getName()
<< " by " << Count);
- Twine DiagMsg("unrolled loop by a factor of " + Twine(Count));
if (TripMultiple == 0 || BreakoutTrip != TripMultiple) {
DEBUG(dbgs() << " with a breakout at trip " << BreakoutTrip);
- DiagMsg.concat(" with a breakout at trip " + Twine(BreakoutTrip));
+ EmitDiag(" with a breakout at trip " + Twine(BreakoutTrip));
} else if (TripMultiple != 1) {
DEBUG(dbgs() << " with " << TripMultiple << " trips per branch");
- DiagMsg.concat(" with " + Twine(TripMultiple) + " trips per branch");
+ EmitDiag(" with " + Twine(TripMultiple) + " trips per branch");
} else if (RuntimeTripCount) {
DEBUG(dbgs() << " with run-time trip count");
- DiagMsg.concat(" with run-time trip count");
+ EmitDiag(" with run-time trip count");
}
DEBUG(dbgs() << "!\n");
- emitOptimizationRemark(Ctx, DEBUG_TYPE, *F, LoopLoc, DiagMsg);
}
bool ContinueOnTrue = L->contains(BI->getSuccessor(0));
More information about the llvm-commits
mailing list