[PATCH] D105838: [GlobalOpt] Fix a miscompile when evaluating struct initializers.

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 14 11:10:09 PDT 2021


efriedma added inline comments.


================
Comment at: llvm/lib/Transforms/Utils/Evaluator.cpp:374
+            // The conversion is illegal if the store is wider than the
+            // proposed bitcast load, since that would drop stores to other
+            // struct elements when `evaluateBitcastFromPtr` attempts to look
----------------
"proposed bitcast load" doesn't make sense.  Do you mean to say "The conversion is illegal if the stored type is narrower than the type of the memory location"?

The code would probably be easier to understand if MutatedMemory was represented using a tuple of "(GlobalVariable, Offset, Size)", or something like that, instead of trying to do a delicate dance with ConstantExprs.  But you don't need to do that rewrite here.


================
Comment at: llvm/lib/Transforms/Utils/Evaluator.cpp:379
+            Type *STy = cast<PointerType>(SI->getPointerOperandType())
+                            ->getElementType();
+            if (DL.getTypeSizeInBits(NewTy) < DL.getTypeSizeInBits(STy))
----------------
This is a weird way to write `Val->getType()`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105838/new/

https://reviews.llvm.org/D105838



More information about the llvm-commits mailing list