Commit cc5cda0f by Antonio Maiorano

LLVMReactor: set alignment when allocating stack variables

Bug: none Change-Id: I1e9d97e95fea1e9c2863211c711feda6d794a825 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/45268 Kokoro-Result: kokoro <noreply+kokoro@google.com> Tested-by: 's avatarAntonio Maiorano <amaiorano@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent b6e8c3f0
......@@ -26,6 +26,9 @@
#if LLVM_VERSION_MAJOR >= 9
# include "llvm/IR/IntrinsicsX86.h"
#endif
#if LLVM_VERSION_MAJOR >= 10
# include "llvm/Support/Alignment.h"
#endif
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/IR/Verifier.h"
#include "llvm/Transforms/Coroutines.h"
......@@ -747,13 +750,21 @@ Value *Nucleus::allocateStackVariable(Type *type, int arraySize)
llvm::Instruction *declaration;
#if LLVM_VERSION_MAJOR >= 11
auto align = jit->module->getDataLayout().getPrefTypeAlign(T(type));
#elif LLVM_VERSION_MAJOR >= 10
auto align = llvm::MaybeAlign(jit->module->getDataLayout().getPrefTypeAlignment(T(type)));
#else
auto align = jit->module->getDataLayout().getPrefTypeAlignment(T(type));
#endif
if(arraySize)
{
declaration = new llvm::AllocaInst(T(type), 0, V(Nucleus::createConstantInt(arraySize)));
declaration = new llvm::AllocaInst(T(type), 0, V(Nucleus::createConstantInt(arraySize)), align);
}
else
{
declaration = new llvm::AllocaInst(T(type), 0, (llvm::Value *)nullptr);
declaration = new llvm::AllocaInst(T(type), 0, (llvm::Value *)nullptr, align);
}
entryBlock.getInstList().push_front(declaration);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment