mirror of
https://github.com/RPCSX/llvm.git
synced 2025-05-13 19:06:05 +00:00
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213027 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7137eb36e1
commit
cbebdef6eb
@ -582,7 +582,7 @@ to over-align the global if the global has an assigned section. In this
|
|||||||
case, the extra alignment could be observable: for example, code could
|
case, the extra alignment could be observable: for example, code could
|
||||||
assume that the globals are densely packed in their section and try to
|
assume that the globals are densely packed in their section and try to
|
||||||
iterate over them as an array, alignment padding would break this
|
iterate over them as an array, alignment padding would break this
|
||||||
iteration.
|
iteration. The maximum alignment is ``1 << 29``.
|
||||||
|
|
||||||
Globals can also have a :ref:`DLL storage class <dllstorageclass>`.
|
Globals can also have a :ref:`DLL storage class <dllstorageclass>`.
|
||||||
|
|
||||||
@ -4925,9 +4925,10 @@ bytes of memory on the runtime stack, returning a pointer of the
|
|||||||
appropriate type to the program. If "NumElements" is specified, it is
|
appropriate type to the program. If "NumElements" is specified, it is
|
||||||
the number of elements allocated, otherwise "NumElements" is defaulted
|
the number of elements allocated, otherwise "NumElements" is defaulted
|
||||||
to be one. If a constant alignment is specified, the value result of the
|
to be one. If a constant alignment is specified, the value result of the
|
||||||
allocation is guaranteed to be aligned to at least that boundary. If not
|
allocation is guaranteed to be aligned to at least that boundary. The
|
||||||
specified, or if zero, the target can choose to align the allocation on
|
alignment may not be greater than ``1 << 29``. If not specified, or if
|
||||||
any convenient boundary compatible with the type.
|
zero, the target can choose to align the allocation on any convenient
|
||||||
|
boundary compatible with the type.
|
||||||
|
|
||||||
'``type``' may be any sized type.
|
'``type``' may be any sized type.
|
||||||
|
|
||||||
@ -5001,7 +5002,8 @@ or an omitted ``align`` argument means that the operation has the ABI
|
|||||||
alignment for the target. It is the responsibility of the code emitter
|
alignment for the target. It is the responsibility of the code emitter
|
||||||
to ensure that the alignment information is correct. Overestimating the
|
to ensure that the alignment information is correct. Overestimating the
|
||||||
alignment results in undefined behavior. Underestimating the alignment
|
alignment results in undefined behavior. Underestimating the alignment
|
||||||
may produce less efficient code. An alignment of 1 is always safe.
|
may produce less efficient code. An alignment of 1 is always safe. The
|
||||||
|
maximum possible alignment is ``1 << 29``.
|
||||||
|
|
||||||
The optional ``!nontemporal`` metadata must reference a single
|
The optional ``!nontemporal`` metadata must reference a single
|
||||||
metadata name ``<index>`` corresponding to a metadata node with one
|
metadata name ``<index>`` corresponding to a metadata node with one
|
||||||
@ -5087,7 +5089,7 @@ alignment for the target. It is the responsibility of the code emitter
|
|||||||
to ensure that the alignment information is correct. Overestimating the
|
to ensure that the alignment information is correct. Overestimating the
|
||||||
alignment results in undefined behavior. Underestimating the
|
alignment results in undefined behavior. Underestimating the
|
||||||
alignment may produce less efficient code. An alignment of 1 is always
|
alignment may produce less efficient code. An alignment of 1 is always
|
||||||
safe.
|
safe. The maximum possible alignment is ``1 << 29``.
|
||||||
|
|
||||||
The optional ``!nontemporal`` metadata must reference a single metadata
|
The optional ``!nontemporal`` metadata must reference a single metadata
|
||||||
name ``<index>`` corresponding to a metadata node with one ``i32`` entry of
|
name ``<index>`` corresponding to a metadata node with one ``i32`` entry of
|
||||||
|
@ -380,6 +380,8 @@ void Verifier::visitGlobalValue(const GlobalValue &GV) {
|
|||||||
"Global is external, but doesn't have external or weak linkage!",
|
"Global is external, but doesn't have external or weak linkage!",
|
||||||
&GV);
|
&GV);
|
||||||
|
|
||||||
|
Assert1(GV.getAlignment() <= Value::MaximumAlignment,
|
||||||
|
"huge alignment values are unsupported", &GV);
|
||||||
Assert1(!GV.hasAppendingLinkage() || isa<GlobalVariable>(GV),
|
Assert1(!GV.hasAppendingLinkage() || isa<GlobalVariable>(GV),
|
||||||
"Only global variables can have appending linkage!", &GV);
|
"Only global variables can have appending linkage!", &GV);
|
||||||
|
|
||||||
@ -1891,6 +1893,8 @@ void Verifier::visitLoadInst(LoadInst &LI) {
|
|||||||
Type *ElTy = PTy->getElementType();
|
Type *ElTy = PTy->getElementType();
|
||||||
Assert2(ElTy == LI.getType(),
|
Assert2(ElTy == LI.getType(),
|
||||||
"Load result type does not match pointer operand type!", &LI, ElTy);
|
"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()) {
|
if (LI.isAtomic()) {
|
||||||
Assert1(LI.getOrdering() != Release && LI.getOrdering() != AcquireRelease,
|
Assert1(LI.getOrdering() != Release && LI.getOrdering() != AcquireRelease,
|
||||||
"Load cannot have Release ordering", &LI);
|
"Load cannot have Release ordering", &LI);
|
||||||
@ -1966,6 +1970,8 @@ void Verifier::visitStoreInst(StoreInst &SI) {
|
|||||||
Assert2(ElTy == SI.getOperand(0)->getType(),
|
Assert2(ElTy == SI.getOperand(0)->getType(),
|
||||||
"Stored value type does not match pointer operand type!",
|
"Stored value type does not match pointer operand type!",
|
||||||
&SI, ElTy);
|
&SI, ElTy);
|
||||||
|
Assert1(SI.getAlignment() <= Value::MaximumAlignment,
|
||||||
|
"huge alignment values are unsupported", &SI);
|
||||||
if (SI.isAtomic()) {
|
if (SI.isAtomic()) {
|
||||||
Assert1(SI.getOrdering() != Acquire && SI.getOrdering() != AcquireRelease,
|
Assert1(SI.getOrdering() != Acquire && SI.getOrdering() != AcquireRelease,
|
||||||
"Store cannot have Acquire ordering", &SI);
|
"Store cannot have Acquire ordering", &SI);
|
||||||
@ -1997,6 +2003,8 @@ void Verifier::visitAllocaInst(AllocaInst &AI) {
|
|||||||
&AI);
|
&AI);
|
||||||
Assert1(AI.getArraySize()->getType()->isIntegerTy(),
|
Assert1(AI.getArraySize()->getType()->isIntegerTy(),
|
||||||
"Alloca array size must have integer type", &AI);
|
"Alloca array size must have integer type", &AI);
|
||||||
|
Assert1(AI.getAlignment() <= Value::MaximumAlignment,
|
||||||
|
"huge alignment values are unsupported", &AI);
|
||||||
|
|
||||||
visitInstruction(AI);
|
visitInstruction(AI);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user