diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2012-07-20 21:09:18 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2012-07-20 21:09:18 +0000 |
commit | 7325f06051bab14196ab3701d515f5b110cefe26 (patch) | |
tree | 5b58a9d157fa3b61d70bebe8da71af7a107e40c3 /lib/VMCore/AutoUpgrade.cpp | |
parent | c321a20b2e250a755bd06f36d896d00d9fd396ad (diff) |
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
Diffstat (limited to 'lib/VMCore/AutoUpgrade.cpp')
-rw-r--r-- | lib/VMCore/AutoUpgrade.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/VMCore/AutoUpgrade.cpp b/lib/VMCore/AutoUpgrade.cpp index f0de5c2fff..094ca75513 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(); |