diff options
author | Reid Kleckner <reid@kleckner.net> | 2014-07-15 01:16:09 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2014-07-15 01:16:09 +0000 |
commit | 15fe7a530d352aecea65f952e6b321635b4fe2a8 (patch) | |
tree | bc57a8dd18688ae152d2f3d1198784096ae07528 /llvm/lib/IR | |
parent | 3151463091b6a0ffb40e1a485e9e14f56f527b18 (diff) | |
download | bcm5719-llvm-15fe7a530d352aecea65f952e6b321635b4fe2a8.tar.gz bcm5719-llvm-15fe7a530d352aecea65f952e6b321635b4fe2a8.zip |
Document the maximum LLVM IR alignment, which is 1 << 29 or 0.5 GiB
Add verifier checks. We already check these in the assembly parser, but
a frontend producing IR in memory wouldn't hit those checks.
llvm-svn: 213027
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r-- | llvm/lib/IR/Verifier.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index ec7ae3a77a7..9cf911b51a4 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -380,6 +380,8 @@ void Verifier::visitGlobalValue(const GlobalValue &GV) { "Global is external, but doesn't have external or weak linkage!", &GV); + Assert1(GV.getAlignment() <= Value::MaximumAlignment, + "huge alignment values are unsupported", &GV); Assert1(!GV.hasAppendingLinkage() || isa<GlobalVariable>(GV), "Only global variables can have appending linkage!", &GV); @@ -1891,6 +1893,8 @@ void Verifier::visitLoadInst(LoadInst &LI) { Type *ElTy = PTy->getElementType(); Assert2(ElTy == LI.getType(), "Load result type does not match pointer operand type!", &LI, ElTy); + Assert1(LI.getAlignment() <= Value::MaximumAlignment, + "huge alignment values are unsupported", &LI); if (LI.isAtomic()) { Assert1(LI.getOrdering() != Release && LI.getOrdering() != AcquireRelease, "Load cannot have Release ordering", &LI); @@ -1966,6 +1970,8 @@ void Verifier::visitStoreInst(StoreInst &SI) { Assert2(ElTy == SI.getOperand(0)->getType(), "Stored value type does not match pointer operand type!", &SI, ElTy); + Assert1(SI.getAlignment() <= Value::MaximumAlignment, + "huge alignment values are unsupported", &SI); if (SI.isAtomic()) { Assert1(SI.getOrdering() != Acquire && SI.getOrdering() != AcquireRelease, "Store cannot have Acquire ordering", &SI); @@ -1997,6 +2003,8 @@ void Verifier::visitAllocaInst(AllocaInst &AI) { &AI); Assert1(AI.getArraySize()->getType()->isIntegerTy(), "Alloca array size must have integer type", &AI); + Assert1(AI.getAlignment() <= Value::MaximumAlignment, + "huge alignment values are unsupported", &AI); visitInstruction(AI); } |