[PATCH] D122821: CallBase: fix getFnAttr so it also checks the function

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 1 03:35:59 PDT 2022


nikic added inline comments.


================
Comment at: llvm/include/llvm/IR/InstrTypes.h:2308
 
+  template <typename AK> Attribute getFnAttrOnCalledFunction(AK Kind) const {
+    // Operand bundles override attributes on the called function, but don't
----------------
durin42 wrote:
> jyknight wrote:
> > Probably best to put this fn next to hasFnAttrOnCalledFunction in the cc file?
> But it's a template, so it has to be in the header, right?
You can either make it a non-template (like the functions above), or you can add an explicit template instantiation in the source file, like so:

```
template Attribute getFnAttrOnCalledFunction(Attribute::AttrKind Kind) const;
template Attribute getFnAttrOnCalledFunction(StringRef Kind) const;
```


================
Comment at: llvm/include/llvm/IR/InstrTypes.h:1625
   Attribute getFnAttr(Attribute::AttrKind Kind) const {
-    return getAttributes().getFnAttr(Kind);
+    if (Attrs.hasFnAttr(Kind))
+      return getAttributes().getFnAttr(Kind);
----------------
Same here, this should use getFnAttr() + isValid().


================
Comment at: llvm/test/Transforms/OpenMP/remove_globalization.ll:35
 ; CHECK-NEXT:    call void @bar() #[[ATTR0]]
-; CHECK-NEXT:    call void @unknown_no_openmp() #[[ATTR5:[0-9]+]]
+; CHECK-NEXT:    call void @unknown_no_openmp()
 ; CHECK-NEXT:    call void @__kmpc_target_deinit(%struct.ident_t* nonnull null, i8 1, i1 true)
----------------
Hm, why do these test changes happen?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122821



More information about the llvm-commits mailing list