Allow DataLayout to specify addrspace for allocas.
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Mon, 10 Apr 2017 22:27:50 +0000 (22:27 +0000)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Mon, 10 Apr 2017 22:27:50 +0000 (22:27 +0000)
commit3c1fc768ed6cf2b01463df036ae6ae3b1f0de632
tree7893b430cd0be51c8e7e2db97e49415820615c83
parentd78bd57b3f24ba97c2b0112d2cf6b5a6896fd67d
Allow DataLayout to specify addrspace for allocas.

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.

llvm-svn: 299888
34 files changed:
llvm/docs/LangRef.rst
llvm/include/llvm/IR/DataLayout.h
llvm/include/llvm/IR/IRBuilder.h
llvm/include/llvm/IR/Instructions.h
llvm/lib/AsmParser/LLParser.cpp
llvm/lib/AsmParser/LLParser.h
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/lib/CodeGen/SjLjEHPrepare.cpp
llvm/lib/CodeGen/WinEHPrepare.cpp
llvm/lib/IR/AsmWriter.cpp
llvm/lib/IR/DataLayout.cpp
llvm/lib/IR/Instructions.cpp
llvm/lib/IR/Verifier.cpp
llvm/lib/Target/NVPTX/NVPTXLowerArgs.cpp
llvm/lib/Transforms/Coroutines/CoroElide.cpp
llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
llvm/lib/Transforms/IPO/GlobalOpt.cpp
llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
llvm/lib/Transforms/Scalar/SROA.cpp
llvm/lib/Transforms/Utils/CodeExtractor.cpp
llvm/lib/Transforms/Utils/DemoteRegToStack.cpp
llvm/lib/Transforms/Utils/InlineFunction.cpp
llvm/test/Assembler/alloca-addrspace-parse-error-0.ll [new file with mode: 0644]
llvm/test/Assembler/alloca-addrspace-parse-error-1.ll [new file with mode: 0644]
llvm/test/Assembler/alloca-addrspace0.ll [new file with mode: 0644]
llvm/test/Assembler/datalayout-alloca-addrspace-mismatch-0.ll [new file with mode: 0644]
llvm/test/Assembler/datalayout-alloca-addrspace-mismatch-1.ll [new file with mode: 0644]
llvm/test/Assembler/datalayout-alloca-addrspace-mismatch-2.ll [new file with mode: 0644]
llvm/test/Assembler/datalayout-alloca-addrspace.ll [new file with mode: 0644]
llvm/test/Assembler/invalid-datalayout-alloca-addrspace.ll [new file with mode: 0644]
llvm/test/Transforms/SROA/alloca-address-space.ll [new file with mode: 0644]
llvm/tools/llvm-stress/llvm-stress.cpp
llvm/unittests/Analysis/ScalarEvolutionTest.cpp