[Lldb-commits] [PATCH] Fix IRInterpreter guard variable replacement.

Zachary Turner zturner at google.com
Tue Jan 6 15:45:53 PST 2015


+Sean Callanan <scallanan at apple.com>​

I couldn't include you on the Phabricator issue Sean, so I'm CC'ing you
directly.  PTAL

On Tue Jan 06 2015 at 3:45:04 PM Zachary Turner <zturner at google.com> wrote:

> MS ABI guard variables end with @4IA, so this patch teaches the
> interpreter about that.  Additionally, there was an issue with
> TurnGuardLoadIntoZero which was causing some guard uses of a variable to be
> missed.  This fixes that by calling Instruction::replaceAllUsesWith()
> instead of trying to replicate that function.
>
> This fixes between 8 and 10 tests on Windows, and in particular fixes
> evaluation of C / C++ local variables.
>
> http://reviews.llvm.org/D6859
>
> Files:
>   source/Expression/IRForTarget.cpp
>
> Index: source/Expression/IRForTarget.cpp
> ===================================================================
> --- source/Expression/IRForTarget.cpp
> +++ source/Expression/IRForTarget.cpp
> @@ -2043,8 +2043,12 @@
>
>      GlobalVariable *GV = dyn_cast<GlobalVariable>(Old);
>
> -    if (!GV || !GV->hasName() || !GV->getName().startswith("_ZGV"))
> +    if (!GV || !GV->hasName() ||
> +        (!GV->getName().startswith("_ZGV") && // Itanium ABI guard
> variable
> +         !GV->getName().endswith("@4IA")))    // Microsoft ABI guard
> variable
> +    {
>          return false;
> +    }
>
>      return true;
>  }
> @@ -2052,20 +2056,8 @@
>  void
>  IRForTarget::TurnGuardLoadIntoZero(llvm::Instruction* guard_load)
>  {
> -    Constant* zero(ConstantInt::get(Type::getInt8Ty(m_module->getContext()),
> 0, true));
> -
> -    for (llvm::User *u : guard_load->users())
> -    {
> -        if (isa<Constant>(u))
> -        {
> -            // do nothing for the moment
> -        }
> -        else
> -        {
> -            u->replaceUsesOfWith(guard_load, zero);
> -        }
> -    }
> -
> +    Constant *zero(Constant::getNullValue(guard_load->getType()));
> +    guard_load->replaceAllUsesWith(zero);
>      guard_load->eraseFromParent();
>  }
>
> EMAIL PREFERENCES
>   http://reviews.llvm.org/settings/panel/emailpreferences/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150106/d430f8fe/attachment.html>


More information about the lldb-commits mailing list