aboutsummaryrefslogtreecommitdiffstats
path: root/lib/IR/Core.cpp
diff options
context:
space:
mode:
authorAnders Waldenborg <anders@0x63.nu>2013-10-29 09:02:02 +0000
committerAnders Waldenborg <anders@0x63.nu>2013-10-29 09:02:02 +0000
commit7959f209ba8e63ffaf7335842deddda4ca0480e7 (patch)
tree8f825bc532751682044f2d09ed4a800337a4a447 /lib/IR/Core.cpp
parentfd4937fe2a0a2bbceeff8ba14e49411c0ae78855 (diff)
downloadexternal_llvm-7959f209ba8e63ffaf7335842deddda4ca0480e7.zip
external_llvm-7959f209ba8e63ffaf7335842deddda4ca0480e7.tar.gz
external_llvm-7959f209ba8e63ffaf7335842deddda4ca0480e7.tar.bz2
llvm-c: Make LLVM{Get,Set}Alignment work on {Load,Store}Inst too
Patch by Peter Zotov Differential Revision: http://llvm-reviews.chandlerc.com/D1910 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193597 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR/Core.cpp')
-rw-r--r--lib/IR/Core.cpp26
1 files changed, 22 insertions, 4 deletions
diff --git a/lib/IR/Core.cpp b/lib/IR/Core.cpp
index 16af733..f681b2e 100644
--- a/lib/IR/Core.cpp
+++ b/lib/IR/Core.cpp
@@ -1240,12 +1240,30 @@ void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz) {
->setVisibility(static_cast<GlobalValue::VisibilityTypes>(Viz));
}
-unsigned LLVMGetAlignment(LLVMValueRef Global) {
- return unwrap<GlobalValue>(Global)->getAlignment();
+/*--.. Operations on global variables, load and store instructions .........--*/
+
+unsigned LLVMGetAlignment(LLVMValueRef V) {
+ Value *P = unwrap<Value>(V);
+ if (GlobalValue *GV = dyn_cast<GlobalValue>(P))
+ return GV->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");
}
-void LLVMSetAlignment(LLVMValueRef Global, unsigned Bytes) {
- unwrap<GlobalValue>(Global)->setAlignment(Bytes);
+void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes) {
+ Value *P = unwrap<Value>(V);
+ if (GlobalValue *GV = dyn_cast<GlobalValue>(P))
+ GV->setAlignment(Bytes);
+ else if (LoadInst *LI = dyn_cast<LoadInst>(P))
+ LI->setAlignment(Bytes);
+ else if (StoreInst *SI = dyn_cast<StoreInst>(P))
+ SI->setAlignment(Bytes);
+
+ llvm_unreachable("only GlobalValue, LoadInst and StoreInst have alignment");
}
/*--.. Operations on global variables ......................................--*/