[PATCH] D73606: [X86] matchAdd: don't fold a large offset into a %rip relative address
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 28 23:37:55 PST 2020
MaskRay added a comment.
`absl/hash/internal/hash.h` takes the address of a static variable `absl::hash_internal::CityHashState::kSeed`:
ABSL_ATTRIBUTE_ALWAYS_INLINE static uint64_t Seed() {
return static_cast<uint64_t>(reinterpret_cast<uintptr_t>(kSeed));
}
static const void* const kSeed;
With certain LTO optimizations, the address can be added to a large constant 1701208431. It is similar to `ret i64 add (i64 ptrtoint (i32* @foo to i64), i64 1701208431)`.
Before this patch, we could produce an instruction like `leaq kSeed+1701208431(%rip), %rax`. At the linking stage, it is an `R_X86_64_PC32` relocation overflow if `kSeed-rip+1701208431 >= 0x80000000`. This means kSeed-rip cannot be larger than 0x80000000-1701208431=0x1a999e91. This upper bound is not large, and some large programs can exceed the bound.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D73606/new/
https://reviews.llvm.org/D73606
More information about the llvm-commits
mailing list