From 7325f06051bab14196ab3701d515f5b110cefe26 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Fri, 20 Jul 2012 21:09:18 +0000 Subject: Fix a dangling StringRef bug in the auto upgrader. In one case, we reset CI's name, and then used the StringRef pointing at its old name. I'm fixing it by storing the name in a std::string, and hoisting the renaming logic to happen always. This is nicer anyways as it will allow the upgraded IR to have the same names as the input IR in more cases. Another bug found by AddressSanitizer. Woot. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160572 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/VMCore/AutoUpgrade.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/VMCore') diff --git a/lib/VMCore/AutoUpgrade.cpp b/lib/VMCore/AutoUpgrade.cpp index f0de5c2..094ca75 100644 --- a/lib/VMCore/AutoUpgrade.cpp +++ b/lib/VMCore/AutoUpgrade.cpp @@ -300,7 +300,8 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) { return; } - StringRef Name = CI->getName(); + std::string Name = CI->getName().str(); + CI->setName(Name + ".old"); switch (NewFn->getIntrinsicID()) { default: @@ -310,7 +311,6 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) { case Intrinsic::cttz: assert(CI->getNumArgOperands() == 1 && "Mismatch between function args and call args"); - CI->setName(Name + ".old"); CI->replaceAllUsesWith(Builder.CreateCall2(NewFn, CI->getArgOperand(0), Builder.getFalse(), Name)); CI->eraseFromParent(); -- cgit v1.1