From 9dcf889d15dc28203a1e001c0a562920377b8337 Mon Sep 17 00:00:00 2001 From: Johannes Doerfert Date: Sat, 11 Jan 2020 23:59:36 -0600 Subject: [PATCH] [Attributor][NFC] Do not (try to) simplify void values We might accidentally ask AAValueSimplify to simplify a void value. That can lead to very interesting, and very wrong, results. We now handle this case gracefully. --- llvm/lib/Transforms/IPO/Attributor.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp index 527cacc..46e5c16 100644 --- a/llvm/lib/Transforms/IPO/Attributor.cpp +++ b/llvm/lib/Transforms/IPO/Attributor.cpp @@ -4131,6 +4131,12 @@ struct AANoCaptureCallSiteReturned final : AANoCaptureImpl { struct AAValueSimplifyImpl : AAValueSimplify { AAValueSimplifyImpl(const IRPosition &IRP) : AAValueSimplify(IRP) {} + /// See AbstractAttribute::initialize(...). + void initialize(Attributor &A) override { + if (getAssociatedValue().getType()->isVoidTy()) + indicatePessimisticFixpoint(); + } + /// See AbstractAttribute::getAsStr(). const std::string getAsStr() const override { return getAssumed() ? (getKnown() ? "simplified" : "maybe-simple") @@ -4146,7 +4152,6 @@ struct AAValueSimplifyImpl : AAValueSimplify { return const_cast(&getAssociatedValue()); return SimplifiedAssociatedValue; } - void initialize(Attributor &A) override {} /// Helper function for querying AAValueSimplify and updating candicate. /// \param QueryingValue Value trying to unify with SimplifiedValue -- 2.7.4