mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-28 19:25:00 +00:00
Define a maximum supported alignment value for load, store, and
alloca instructions (constrained by their internal encoding), and add error checking for it. Fix an instcombine bug which generated huge alignment values (null is infinitely aligned). This fixes undefined behavior noticed by John Regehr. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109643 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -891,6 +891,8 @@ AllocaInst::~AllocaInst() {
|
||||
|
||||
void AllocaInst::setAlignment(unsigned Align) {
|
||||
assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!");
|
||||
assert(Align <= MaximumAlignment &&
|
||||
"Alignment is greater than MaximumAlignment!");
|
||||
setInstructionSubclassData(Log2_32(Align) + 1);
|
||||
assert(getAlignment() == Align && "Alignment representation error!");
|
||||
}
|
||||
@@ -1026,8 +1028,11 @@ LoadInst::LoadInst(Value *Ptr, const char *Name, bool isVolatile,
|
||||
|
||||
void LoadInst::setAlignment(unsigned Align) {
|
||||
assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!");
|
||||
assert(Align <= MaximumAlignment &&
|
||||
"Alignment is greater than MaximumAlignment!");
|
||||
setInstructionSubclassData((getSubclassDataFromInstruction() & 1) |
|
||||
((Log2_32(Align)+1)<<1));
|
||||
assert(getAlignment() == Align && "Alignment representation error!");
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
@@ -1122,8 +1127,11 @@ StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile,
|
||||
|
||||
void StoreInst::setAlignment(unsigned Align) {
|
||||
assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!");
|
||||
assert(Align <= MaximumAlignment &&
|
||||
"Alignment is greater than MaximumAlignment!");
|
||||
setInstructionSubclassData((getSubclassDataFromInstruction() & 1) |
|
||||
((Log2_32(Align)+1) << 1));
|
||||
assert(getAlignment() == Align && "Alignment representation error!");
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
Reference in New Issue
Block a user