[PATCH] D24436: Fix misleading comment for getOrEnforceKnownAlignment

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 9 18:12:59 PDT 2016


arsenm created this revision.
arsenm added reviewers: jlebar, efriedma.
arsenm added a subscriber: llvm-commits.
Herald added a subscriber: wdng.

It does not return 0 to indicate failure, and returns the known alignment.

https://reviews.llvm.org/D24436

Files:
  include/llvm/Transforms/Utils/Local.h
  lib/Transforms/Utils/Local.cpp

Index: lib/Transforms/Utils/Local.cpp
===================================================================
--- lib/Transforms/Utils/Local.cpp
+++ lib/Transforms/Utils/Local.cpp
@@ -1001,10 +1001,6 @@
   return Align;
 }
 
-/// getOrEnforceKnownAlignment - If the specified pointer has an alignment that
-/// we can determine, return it, otherwise return 0.  If PrefAlign is specified,
-/// and it is more than the alignment of the ultimate object, see if we can
-/// increase the alignment of the ultimate object, making this check succeed.
 unsigned llvm::getOrEnforceKnownAlignment(Value *V, unsigned PrefAlign,
                                           const DataLayout &DL,
                                           const Instruction *CxtI,
Index: include/llvm/Transforms/Utils/Local.h
===================================================================
--- include/llvm/Transforms/Utils/Local.h
+++ include/llvm/Transforms/Utils/Local.h
@@ -161,10 +161,14 @@
 /// deleted and it returns the pointer to the alloca inserted.
 AllocaInst *DemotePHIToStack(PHINode *P, Instruction *AllocaPoint = nullptr);
 
-/// If the specified pointer has an alignment that we can determine, return it,
-/// otherwise return 0. If PrefAlign is specified, and it is more than the
-/// alignment of the ultimate object, see if we can increase the alignment of
-/// the ultimate object, making this check succeed.
+/// If \p PrefAlign is more than the alignment of the ultimate object the
+/// specified pointer is derived from that we control, modify the object's
+/// alignment to PrefAlign. This isn't often possible though. If alignment is
+/// important, a more reliable approach is to simply align all global variables
+/// and allocation instructions to their preferred alignment from the beginning.
+///
+/// If the alignment cannot be modified, return the determined alignment value.
+///
 unsigned getOrEnforceKnownAlignment(Value *V, unsigned PrefAlign,
                                     const DataLayout &DL,
                                     const Instruction *CxtI = nullptr,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24436.70938.patch
Type: text/x-patch
Size: 2081 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160910/eb3fdd3e/attachment.bin>


More information about the llvm-commits mailing list