[PATCH] D45198: [GlobalOpt] Fix support for casts in ctors.

Eugene Leviant via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 6 04:17:05 PDT 2018


evgeny777 accepted this revision.
evgeny777 added a comment.
This revision is now accepted and ready to land.

LGTM with nit.



================
Comment at: lib/Transforms/Utils/Evaluator.cpp:208
+      Constant *Orig = nullptr;
+      auto MM = MutatedMemory.find(Val);
+      if (MM != MutatedMemory.end())
----------------
mtrofin wrote:
> evgeny777 wrote:
> > It looks like we can get into the same trouble when evaluating GEP as well. So probably move this to getInitializer() ?
> That's what I thought, too, but I'm having trouble producing a testcase. Replacing the bitcast here with a GEP (and performing the necessary adjustments) "just works".
Well it looks like the GEP case is handled in the very beginning of `ComputeLoadResult`, so nothing really should be done with it


================
Comment at: lib/Transforms/Utils/Evaluator.cpp:211
+        Orig = MM->second;
+      else if (auto *I = getInitializer(CE->getOperand(0)))
+        Orig = I;
----------------
Please change if .. else  to ternary operator:
```
auto *I = (MM != MutatedMemory.end) ? MM->second : getInitializer(CE->getOperand(0));
if (I)
  ConstantFoldLoadThroughBitcast(I, ...);
```


Repository:
  rL LLVM

https://reviews.llvm.org/D45198





More information about the llvm-commits mailing list