[llvm] r220392 - Preserving 'nonnull' metadata in SimplifyCFG

Philip Reames listmail at philipreames.com
Wed Oct 22 09:37:14 PDT 2014


Author: reames
Date: Wed Oct 22 11:37:13 2014
New Revision: 220392

URL: http://llvm.org/viewvc/llvm-project?rev=220392&view=rev
Log:
Preserving 'nonnull' metadata in SimplifyCFG

When we hoist two loads above an if, we can preserve the nonnull metadata.  We could also do the same for sinking them, but we appear to not handle metadata at all in that case.

Thanks to Hal for the review.

Differential Revision: http://reviews.llvm.org/D5910


Modified:
    llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp

Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=220392&r1=220391&r2=220392&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Wed Oct 22 11:37:13 2014
@@ -1061,7 +1061,8 @@ static bool HoistThenElseCodeToIf(Branch
       LLVMContext::MD_tbaa,
       LLVMContext::MD_range,
       LLVMContext::MD_fpmath,
-      LLVMContext::MD_invariant_load
+      LLVMContext::MD_invariant_load,
+      LLVMContext::MD_nonnull
     };
     combineMetadata(I1, I2, KnownIDs);
     I2->eraseFromParent();
@@ -1311,6 +1312,8 @@ static bool SinkThenElseCodeToEnd(Branch
     if (!I2->use_empty())
       I2->replaceAllUsesWith(I1);
     I1->intersectOptionalDataWith(I2);
+    // TODO: Use combineMetadata here to preserve what metadata we can
+    // (analogous to the hoisting case above).
     I2->eraseFromParent();
 
     if (UpdateRE1)





More information about the llvm-commits mailing list