[llvm] 51fbc1b - Mask out existing alignment bits.
Luqman Aden via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 14 19:37:25 PDT 2020
Author: Luqman Aden
Date: 2020-10-14T19:34:32-07:00
New Revision: 51fbc1bef657bb0f5808986555ec3517a84768c4
URL: https://github.com/llvm/llvm-project/commit/51fbc1bef657bb0f5808986555ec3517a84768c4
DIFF: https://github.com/llvm/llvm-project/commit/51fbc1bef657bb0f5808986555ec3517a84768c4.diff
LOG: Mask out existing alignment bits.
Added:
Modified:
llvm/include/llvm/Object/COFF.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/Object/COFF.h b/llvm/include/llvm/Object/COFF.h
index b50d2c3698a2..e7cf1b5495c6 100644
--- a/llvm/include/llvm/Object/COFF.h
+++ b/llvm/include/llvm/Object/COFF.h
@@ -583,14 +583,14 @@ struct coff_tls_directory {
}
void setAlignment(uint32_t Align) {
- if (!Align) {
- Characteristics &= ~COFF::IMAGE_SCN_ALIGN_MASK;
- } else {
+ uint32_t AlignBits = 0;
+ if (Align) {
assert(llvm::isPowerOf2_32(Align) && "alignment is not a power of 2");
- uint32_t P2Align = llvm::Log2_32(Align);
- assert(P2Align <= 13 && "invalid alignment requested");
- Characteristics |= (P2Align + 1) << 20;
+ assert(llvm::Log2_32(Align) <= 13 && "alignment requested is too large");
+ AlignBits = (llvm::Log2_32(Align) + 1) << 20;
}
+ Characteristics =
+ (Characteristics & ~COFF::IMAGE_SCN_ALIGN_MASK) | AlignBits;
}
};
More information about the llvm-commits
mailing list