mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
[Attributor][FIX] Carefully strip casts in AANoAlias
We can strip casts in AANoAlias but that might cause us to end up with a non-pointer type. We do properly handle that case now.
This commit is contained in:
parent
e6077023d4
commit
23335d87a7
@ -2493,7 +2493,10 @@ struct AAReachabilityFunction final : public AAReachabilityImpl {
|
||||
/// ------------------------ NoAlias Argument Attribute ------------------------
|
||||
|
||||
struct AANoAliasImpl : AANoAlias {
|
||||
AANoAliasImpl(const IRPosition &IRP) : AANoAlias(IRP) {}
|
||||
AANoAliasImpl(const IRPosition &IRP) : AANoAlias(IRP) {
|
||||
assert(getAssociatedType()->isPointerTy() &&
|
||||
"Noalias is a pointer attribute");
|
||||
}
|
||||
|
||||
const std::string getAsStr() const override {
|
||||
return getAssumed() ? "noalias" : "may-alias";
|
||||
@ -2518,6 +2521,11 @@ struct AANoAliasFloating final : AANoAliasImpl {
|
||||
Val = Base;
|
||||
} while (true);
|
||||
|
||||
if (!Val->getType()->isPointerTy()) {
|
||||
indicatePessimisticFixpoint();
|
||||
return;
|
||||
}
|
||||
|
||||
if (isa<AllocaInst>(Val))
|
||||
indicateOptimisticFixpoint();
|
||||
else if (isa<ConstantPointerNull>(Val) &&
|
||||
|
@ -1,4 +1,4 @@
|
||||
; RUN: opt -S -passes=attributor -aa-pipeline='basic-aa' -attributor-disable=false -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=4 < %s | FileCheck %s
|
||||
; RUN: opt -S -passes=attributor -aa-pipeline='basic-aa' -attributor-disable=false -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=7 < %s | FileCheck %s
|
||||
|
||||
; TEST 1 - negative.
|
||||
|
||||
@ -330,3 +330,21 @@ define void @test13_use_alias(){
|
||||
ret void
|
||||
}
|
||||
|
||||
; TEST 14 i2p casts
|
||||
define internal i32 @p2i(i32* %arg) {
|
||||
%p2i = ptrtoint i32* %arg to i32
|
||||
ret i32 %p2i
|
||||
}
|
||||
|
||||
define i32 @i2p(i32* %arg) {
|
||||
%c = call i32 @p2i(i32* %arg)
|
||||
%i2p = inttoptr i32 %c to i8*
|
||||
%bc = bitcast i8* %i2p to i32*
|
||||
%call = call i32 @ret(i32* %bc)
|
||||
ret i32 %call
|
||||
}
|
||||
define internal i32 @ret(i32* %arg) {
|
||||
%l = load i32, i32* %arg
|
||||
ret i32 %l
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user