[PATCH] D29284: [AMDGPU] Lower null pointers in static variable initializer

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 31 10:45:37 PST 2017


arsenm added inline comments.


================
Comment at: lib/Target/AMDGPU/AMDGPUMCInstLower.cpp:162-168
+    if (Op->isNullValue()) {
+      auto SrcAddr = Op->getType()->getPointerAddressSpace();
+      auto DstAddr = CE->getType()->getPointerAddressSpace();
+      if (SrcAddr == AMDGPUAS::FLAT_ADDRESS &&
+          (DstAddr == AMDGPUAS::PRIVATE_ADDRESS ||
+           DstAddr == AMDGPUAS::LOCAL_ADDRESS)) {
+        return MCConstantExpr::create(-1, OutContext);
----------------
We should factor the constant folding of pointers into a single place. The same logic is already repeated in SIISelLowering and I have a need of it in another place.

Maybe we should put a constant fold pointer helper in AMDGPUTargetMachine?


https://reviews.llvm.org/D29284





More information about the llvm-commits mailing list