[PATCH] D71435: [WIP] [Attributor] Function level undefined behavior attribute

Stefanos Baziotis via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 15 18:52:07 PST 2019


baziotis marked an inline comment as done.
baziotis added inline comments.


================
Comment at: llvm/lib/Transforms/IPO/Attributor.cpp:1993
+        if (!canCauseUB) {
+          noUBLoads.insert(I);
+        }
----------------
jdoerfert wrote:
> baziotis wrote:
> > I couldn't find a way to save the entry so that we don't have to search the second (i.e. like in the unordered_map).
> Search the second what? 
> 
> `if (MySmallPtrSet.count(&I))`
> 
> and 
> 
> `MySmallPtrSet.insert(&I)`
> 
> should work just fine.
> 
> Nit: I would not do the `Iref` and `I = &Iref` thing but just use the reference (called `I`) and the `&` as needed.
Search the second what?

> if (MySmallPtrSet.count(&I))

> and

> MySmallPtrSet.insert(&I)

> should work just fine.

Yes, but pretty much `count` would achieve what `find` achieves already right?
What I meant was that imagine that our DS is implemented as a linear probing hash table. Then, you would do one search with find (or count) and then another with insert, but it would be the _same_ search. In an `unordered_map` we can avoid that by caching the search in find, like this:
```
Instruction *&entry = map[I];
if (!entry) {
  // Does not exist, so insert it.
  entry = ...;
}
```
But I don't if this is possible on `std::set` let alone `SmallPtrSet`. It's not that important I guess.

> Nit: I would not do the Iref and I = &Iref thing but just use the reference (called I) and the & as needed.
Noted :)


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

https://reviews.llvm.org/D71435





More information about the llvm-commits mailing list