[PATCH] D11200: Improve merging of stores from static constructors in GlobalOpt

Anthony Pesch inolen at gmail.com
Mon Jul 20 16:50:53 PDT 2015

inolen added a comment.

Thanks again for the review!

Comment at: lib/Transforms/IPO/GlobalOpt.cpp:2011-2012
@@ +2010,4 @@
+    if (ConstantExpr *CE = dyn_cast<ConstantExpr>(Ptr)) {
+      if (CE->getOpcode() == Instruction::GetElementPtr) {
+        return cast<GlobalVariable>(CE->getOperand(0));
+      }
nlewycky wrote:
> Couldn't CE->getOpcode() == Instruction::BitCast also reach here?
As far as I can tell, it shouldn't.

If the store pointer is a bitcast (and it's not folded away), it gets through to the block we were discussing in IRC. If the logic in that block is successful, the pointer is converted into a GEP expression before being added to the map: http://llvm.org/docs/doxygen/html/GlobalOpt_8cpp_source.html#l02342



More information about the llvm-commits mailing list