OSDN Git Service

[Attributor][NFC] Do not (try to) simplify void values
authorJohannes Doerfert <johannes@jdoerfert.de>
Sun, 12 Jan 2020 05:59:36 +0000 (23:59 -0600)
committerJohannes Doerfert <johannes@jdoerfert.de>
Fri, 24 Jan 2020 00:42:45 +0000 (18:42 -0600)
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

index 527cacc..46e5c16 100644 (file)
@@ -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<Value *>(&getAssociatedValue());
     return SimplifiedAssociatedValue;
   }
-  void initialize(Attributor &A) override {}
 
   /// Helper function for querying AAValueSimplify and updating candicate.
   /// \param QueryingValue Value trying to unify with SimplifiedValue