[flang-commits] [flang] [Flang][OpenMP] Make boxed procedure pass aware of OpenMP private ops (PR #118261)

Kiran Chandramohan via flang-commits flang-commits at lists.llvm.org
Wed Dec 4 06:19:34 PST 2024


kiranchandramohan wrote:

> Thanks Kiran for the details, then the only generic solution I see with the current pass would be to also update the TypeAttr attribute in the code that updates the result type (like [what is done for SymbolRefAttr in ExternalNameConversion](https://github.com/llvm/llvm-project/blob/21d27b3aabf3d06f7e8b1002b34bb467f6ab66d8/flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp#L98-L106)).
> 
> If that does not work, you can assign an issue to me and I am OK with your patch.

Thanks @jeanPerier for the reference. Just an update here.

I added something like the following, which iterates through the attributes and updates if it is a typeAttr that needs conversion. This works fine for my usecase.
```
          for (const mlir::NamedAttribute &attr : op->getAttrDictionary())
            if (auto tyAttr = llvm::dyn_cast<mlir::TypeAttr>(attr.getValue()))
              if (typeConverter.needsConversion(tyAttr.getValue())) {
                auto toTy = typeConverter.convertType(tyAttr.getValue());
                op->setAttr(attr.getName(), mlir::TypeAttr::get(toTy));
              }
  ```
  But I see a failure in the gfortan test. I will have a detailed look later this week.
  ```
error: loc("/home/kiran/llvm-test-suite/Fortran/gfortran/regression/typebound_operator_9.f03":280:5): 'fir.type_desc' op wrapped type mismatched
error: loc("/home/kiran/llvm-test-suite/Fortran/gfortran/regression/typebound_operator_9.f03":315:5): 'fir.type_desc' op wrapped type mismatched
error: loc("/home/kiran/llvm-test-suite/Fortran/gfortran/regression/typebound_operator_9.f03":299:5): 'fir.type_desc' op wrapped type mismatched
error: loc("/home/kiran/llvm-test-suite/Fortran/gfortran/regression/typebound_operator_9.f03":228:5): 'fir.type_desc' op wrapped type mismatched
error: loc("/home/kiran/llvm-test-suite/Fortran/gfortran/regression/typebound_operator_9.f03":401:3): 'fir.type_desc' op wrapped type mismatched
              ```

https://github.com/llvm/llvm-project/pull/118261


More information about the flang-commits mailing list