[PATCH] D31042: Allow DataLayout to specify addrspace for allocas.

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 16 10:54:02 PDT 2017


arsenm created this revision.
Herald added subscribers: tpr, wdng, jholewinski.

LLVM makes several assumptions about address space 0. However,
alloca is presently constrained to always return this address space.
There's no real way to avoid using alloca, so without this
there is no way to opt out of these assumptions.

      

The problematic assumptions include:

- That the pointer size used for the stack is the same size as the code size pointer, which is also the maximum sized pointer.

- That 0 is an invalid, non-dereferencable pointer value.

These are problems for AMDGPU because alloca is used to
implement the private address space, which uses a 32-bit
index as the pointer value. Other pointers are 64-bit
and behave more like LLVM's notion of generic address
space. By changing the address space used for allocas,
we can change our generic pointer type to be LLVM's generic
 pointer type which does have similar properties.


https://reviews.llvm.org/D31042

Files:
  docs/LangRef.rst
  include/llvm/IR/DataLayout.h
  include/llvm/IR/IRBuilder.h
  include/llvm/IR/Instructions.h
  lib/AsmParser/LLParser.cpp
  lib/Bitcode/Reader/BitcodeReader.cpp
  lib/CodeGen/AtomicExpandPass.cpp
  lib/CodeGen/SafeStack.cpp
  lib/CodeGen/ShadowStackGCLowering.cpp
  lib/CodeGen/SjLjEHPrepare.cpp
  lib/CodeGen/StackProtector.cpp
  lib/CodeGen/WinEHPrepare.cpp
  lib/IR/Core.cpp
  lib/IR/DataLayout.cpp
  lib/IR/Instructions.cpp
  lib/IR/Verifier.cpp
  lib/Target/NVPTX/NVPTXLowerArgs.cpp
  lib/Target/X86/X86WinEHState.cpp
  lib/Transforms/Coroutines/CoroElide.cpp
  lib/Transforms/Coroutines/CoroSplit.cpp
  lib/Transforms/IPO/ArgumentPromotion.cpp
  lib/Transforms/IPO/GlobalOpt.cpp
  lib/Transforms/InstCombine/InstCombineCasts.cpp
  lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
  lib/Transforms/Instrumentation/AddressSanitizer.cpp
  lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
  lib/Transforms/Instrumentation/MemorySanitizer.cpp
  lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
  lib/Transforms/Scalar/SROA.cpp
  lib/Transforms/Utils/CodeExtractor.cpp
  lib/Transforms/Utils/DemoteRegToStack.cpp
  lib/Transforms/Utils/InlineFunction.cpp
  test/Assembler/datalayout-alloca-addrspace.ll
  test/Assembler/invalid-datalayout-alloca-addrspace.ll
  test/Transforms/SROA/alloca-address-space.ll
  tools/llvm-stress/llvm-stress.cpp
  unittests/Analysis/ScalarEvolutionTest.cpp
  unittests/IR/IRBuilderTest.cpp
  unittests/Transforms/Utils/Cloning.cpp
  unittests/Transforms/Utils/MemorySSA.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31042.92021.patch
Type: text/x-patch
Size: 55458 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170316/b248e023/attachment.bin>


More information about the llvm-commits mailing list