[PATCH] D85127: [ArgPromotion] Replace all md uses of promoted values with undef.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 3 10:28:34 PDT 2020


fhahn added inline comments.


================
Comment at: llvm/lib/Transforms/IPO/ArgumentPromotion.cpp:413
 
-    if (I->use_empty())
+    if (I->use_empty()) {
+      // There potentially are metadata uses left for things like
----------------
aprantl wrote:
> We could use 
> ```
> llvm::scope_exit RauwUndef([&]() {
> // There potentially are metadata uses left for things like
> // llvm.dbg.value. Replace them with undef.
> I->replaceAllUsesWith(UndefValue::get(I->getType()));
> });
> 
> if (I->use_empty())
>   continue;
> ```
> 
> I'll leave it up to you to decide whether that's actually better.
Nice, I wasn't aware of `scope_exit()`! That would allow to get rid of the unfortunate duplication. 

The reason we need to drop at the end of the scope is that there is no `replaceAllMetadataUsesWith` and metadata uses can only be replaced together with regular uses. So alternatively we could also add a replaceAllMetadataUsesWith, but if that's the only place it's probably not worth it. What do you think?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85127/new/

https://reviews.llvm.org/D85127



More information about the llvm-commits mailing list