summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/AutoUpgrade.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2012-07-20 21:09:18 +0000
committerChandler Carruth <chandlerc@gmail.com>2012-07-20 21:09:18 +0000
commit1f41bf0c3f44ac457b9c1da7fc0d18b7d35e8a6f (patch)
tree900e6dedcf86f59bd43429dcbedb53116d119ce8 /llvm/lib/VMCore/AutoUpgrade.cpp
parentf62c07f1470a55f57118e5a24334cf97cb749c59 (diff)
downloadbcm5719-llvm-1f41bf0c3f44ac457b9c1da7fc0d18b7d35e8a6f.tar.gz
bcm5719-llvm-1f41bf0c3f44ac457b9c1da7fc0d18b7d35e8a6f.zip
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. llvm-svn: 160572
Diffstat (limited to 'llvm/lib/VMCore/AutoUpgrade.cpp')
-rw-r--r--llvm/lib/VMCore/AutoUpgrade.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/VMCore/AutoUpgrade.cpp b/llvm/lib/VMCore/AutoUpgrade.cpp
index f0de5c2fff1..094ca755132 100644
--- a/llvm/lib/VMCore/AutoUpgrade.cpp
+++ b/llvm/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();
OpenPOWER on IntegriCloud