summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPeter Zotov <whitequark@whitequark.org>2014-03-05 05:05:34 +0000
committerPeter Zotov <whitequark@whitequark.org>2014-03-05 05:05:34 +0000
commit8a25ef92fb3af998124a1d9770fb7ef7dec84401 (patch)
tree86ede17765e4aaa5d59711e54bd1a88f2778df6f /lib
parentc75dc7412babbd8194e569268008df39a7644da1 (diff)
downloadllvm-8a25ef92fb3af998124a1d9770fb7ef7dec84401.tar.gz
llvm-8a25ef92fb3af998124a1d9770fb7ef7dec84401.tar.bz2
llvm-8a25ef92fb3af998124a1d9770fb7ef7dec84401.tar.xz
[C API] Implement LLVM{Get,Set}Alignment for AllocaInst.
Patch by Manuel Jacob. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202936 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/IR/Core.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/IR/Core.cpp b/lib/IR/Core.cpp
index c78ddae60b..f63263fd1f 100644
--- a/lib/IR/Core.cpp
+++ b/lib/IR/Core.cpp
@@ -1268,24 +1268,30 @@ unsigned LLVMGetAlignment(LLVMValueRef V) {
Value *P = unwrap<Value>(V);
if (GlobalValue *GV = dyn_cast<GlobalValue>(P))
return GV->getAlignment();
+ if (AllocaInst *AI = dyn_cast<AllocaInst>(P))
+ return AI->getAlignment();
if (LoadInst *LI = dyn_cast<LoadInst>(P))
return LI->getAlignment();
if (StoreInst *SI = dyn_cast<StoreInst>(P))
return SI->getAlignment();
- llvm_unreachable("only GlobalValue, LoadInst and StoreInst have alignment");
+ llvm_unreachable(
+ "only GlobalValue, AllocaInst, LoadInst and StoreInst have alignment");
}
void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes) {
Value *P = unwrap<Value>(V);
if (GlobalValue *GV = dyn_cast<GlobalValue>(P))
GV->setAlignment(Bytes);
+ else if (AllocaInst *AI = dyn_cast<AllocaInst>(P))
+ AI->setAlignment(Bytes);
else if (LoadInst *LI = dyn_cast<LoadInst>(P))
LI->setAlignment(Bytes);
else if (StoreInst *SI = dyn_cast<StoreInst>(P))
SI->setAlignment(Bytes);
else
- llvm_unreachable("only GlobalValue, LoadInst and StoreInst have alignment");
+ llvm_unreachable(
+ "only GlobalValue, AllocaInst, LoadInst and StoreInst have alignment");
}
/*--.. Operations on global variables ......................................--*/