diff options
author | Nikita Popov <npopov@redhat.com> | 2022-03-03 15:41:06 +0100 |
---|---|---|
committer | Nikita Popov <npopov@redhat.com> | 2022-03-07 10:02:45 +0100 |
commit | a9b03d9e2e3888ad08f9f0294c6e6bec43d7c884 (patch) | |
tree | 62ab45b48fbae3f97a70e2b9dc3970545b4ef5c6 /llvm/lib/IR/Value.cpp | |
parent | 43b638241aa8c114e5a5b44b38630af43ca9f84f (diff) | |
download | llvm-a9b03d9e2e3888ad08f9f0294c6e6bec43d7c884.zip llvm-a9b03d9e2e3888ad08f9f0294c6e6bec43d7c884.tar.gz llvm-a9b03d9e2e3888ad08f9f0294c6e6bec43d7c884.tar.bz2 |
[Attributor] Remove function pointer restriction for AAAlign
This check is not compatible with opaque pointers. We can avoid
it by adjusting the getPointerAlignment() implementation to avoid
creating unnecessary ptrtoint expressions for bitcasted pointers.
The code already uses OnlyIfReduced to not create an expression
if it does not simplify, and this makes sure that folding a
bitcast and ptrtoint into a ptrtoint doesn't count as a
simplification.
Differential Revision: https://reviews.llvm.org/D120904
Diffstat (limited to 'llvm/lib/IR/Value.cpp')
-rw-r--r-- | llvm/lib/IR/Value.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/llvm/lib/IR/Value.cpp b/llvm/lib/IR/Value.cpp index df286df..3348de6 100644 --- a/llvm/lib/IR/Value.cpp +++ b/llvm/lib/IR/Value.cpp @@ -964,6 +964,9 @@ Align Value::getPointerAlignment(const DataLayout &DL) const { return Align(CI->getLimitedValue()); } } else if (auto *CstPtr = dyn_cast<Constant>(this)) { + // Strip pointer casts to avoid creating unnecessary ptrtoint expression + // if the only "reduction" is combining a bitcast + ptrtoint. + CstPtr = CstPtr->stripPointerCasts(); if (auto *CstInt = dyn_cast_or_null<ConstantInt>(ConstantExpr::getPtrToInt( const_cast<Constant *>(CstPtr), DL.getIntPtrType(getType()), /*OnlyIfReduced=*/true))) { |