[PATCH] D77421: [WPD] Avoid noalias assumptions in unique return value optimization

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 8 13:03:08 PDT 2020


pcc added inline comments.


================
Comment at: llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp:506
+  /// from assuming different names refer to different addresses.
+  ArrayType *VtableTy;
 
----------------
Elsewhere I've called this `Int8Arr0Ty` but I'm not too picky about the name.


================
Comment at: llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp:1404
+  GlobalAlias *GA = GlobalAlias::create(
+      cast<PointerType>(C->getType())->getElementType(), 0,
+      GlobalValue::ExternalLinkage, getGlobalName(Slot, Args, Name), C, &M);
----------------
Is this change necessary? As far as I know we aren't passing the result of `importGlobal` here and it would be nice to avoid introducing a call to `PointerType::getElementType()` given that we hope to eliminate it one day.


================
Comment at: llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp:1437
 
-  Constant *C = importGlobal(Slot, Args, Name);
+  Constant *C = importGlobal(Slot, Args, Name, Int8Ty);
   auto *GV = cast<GlobalVariable>(C->stripPointerCasts());
----------------
The type doesn't matter in this case (in fact it may be slightly more beneficial to use [0 x i8] here in order to allow the absolute symbols to "alias" when their values are the same), so could we just use it everywhere?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77421





More information about the llvm-commits mailing list