This is an archive of the discontinued LLVM Phabricator instance.

[LLVM] move verification of convergence control to a class template
ClosedPublic

Authored by sameerds on Jul 28 2023, 4:34 AM.

Diff Detail

Event Timeline

sameerds created this revision.Jul 28 2023, 4:34 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 28 2023, 4:34 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
sameerds requested review of this revision.Jul 28 2023, 4:34 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 28 2023, 4:34 AM
sameerds added a subscriber: Restricted Project.
arsenm added inline comments.Jul 28 2023, 4:45 AM
llvm/include/llvm/ADT/GenericConvergenceVerifier.h
35

can this be function_ref? I'd expect this to have the failure context as an explicit argument

71

Lowercase?

llvm/lib/IR/Verifier.cpp
395

Don't think you need the everything capture

sameerds updated this revision to Diff 545531.Jul 31 2023, 12:56 AM
  • rebase
  • replaced std::function with function_ref
  • removed the everything capture
  • renamed CheckFailed() to reportFailure() ... more aligned with the coding standard
sameerds marked 3 inline comments as done.Jul 31 2023, 1:00 AM
sameerds added inline comments.
llvm/include/llvm/ADT/GenericConvergenceVerifier.h
35

See the function reportFailure() where the failure context is passed as an ArrayRef<Printable>. Both verifiers use different variadic function templates that do the same thing: print the message, change the verifier state and then print a variable number of context arguments. This lambda is a call-back to do the first two things. reportFailure() calls this lambda and then prints the context objects passed to it.

sameerds marked an inline comment as done.Jul 31 2023, 1:01 AM
sameerds added inline comments.
llvm/test/Verifier/convergencectrl-invalid.ll
3

These extra tests were separately committed to the main branch in

https://reviews.llvm.org/rGf7b09516e466

arsenm accepted this revision.Jul 31 2023, 1:51 PM
This revision is now accepted and ready to land.Jul 31 2023, 1:51 PM
This revision was landed with ongoing or failed builds.Jul 31 2023, 10:52 PM
This revision was automatically updated to reflect the committed changes.

this broke my build with:

ld.lld-12: error: undefined symbol: llvm::GenericCycle<llvm::GenericSSAContext<llvm::Function> >::contains(llvm::BasicBlock const*) const
>>> referenced by UniformityAnalysis.cpp:72 (/home/culrho01/llvm-project/llvm/lib/Analysis/UniformityAnalysis.cpp:72)
>>>               lib/Analysis/CMakeFiles/LLVMAnalysis.dir/UniformityAnalysis.cpp.o:(llvm::GenericUniformityAnalysisImpl<llvm::GenericSSAContext<llvm::Function> >::usesValueFromCycle(llvm::Instruction const&, llvm::GenericCycle<llvm::GenericSSAContext<llvm::Function> > const&) const)

please could you look into it?

this broke my build with:

ld.lld-12: error: undefined symbol: llvm::GenericCycle<llvm::GenericSSAContext<llvm::Function> >::contains(llvm::BasicBlock const*) const
>>> referenced by UniformityAnalysis.cpp:72 (/home/culrho01/llvm-project/llvm/lib/Analysis/UniformityAnalysis.cpp:72)
>>>               lib/Analysis/CMakeFiles/LLVMAnalysis.dir/UniformityAnalysis.cpp.o:(llvm::GenericUniformityAnalysisImpl<llvm::GenericSSAContext<llvm::Function> >::usesValueFromCycle(llvm::Instruction const&, llvm::GenericCycle<llvm::GenericSSAContext<llvm::Function> > const&) const)

please could you look into it?

It's not obvious to me how this change could affect affect functions defined in GenericCycle. Can you please provide the commit hash that you are building, and the build parameters? I will need to reproduced this locally to make any progress.

this broke my build with:

ld.lld-12: error: undefined symbol: llvm::GenericCycle<llvm::GenericSSAContext<llvm::Function> >::contains(llvm::BasicBlock const*) const
>>> referenced by UniformityAnalysis.cpp:72 (/home/culrho01/llvm-project/llvm/lib/Analysis/UniformityAnalysis.cpp:72)
>>>               lib/Analysis/CMakeFiles/LLVMAnalysis.dir/UniformityAnalysis.cpp.o:(llvm::GenericUniformityAnalysisImpl<llvm::GenericSSAContext<llvm::Function> >::usesValueFromCycle(llvm::Instruction const&, llvm::GenericCycle<llvm::GenericSSAContext<llvm::Function> > const&) const)

please could you look into it?

It's not obvious to me how this change could affect affect functions defined in GenericCycle. Can you please provide the commit hash that you are building, and the build parameters? I will need to reproduced this locally to make any progress.

I build with -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Debug, I tried static libs (-DBUILD_SHARED_LIBS=OFF) and that works so I think you'll be able to reproduce with shared libs.

sameerds reopened this revision.Aug 1 2023, 4:54 AM

Reopened this because of build errors with shared libraries enabled.

The "extern template" declaration of CycleInfo caused problems in a shared build when CycleInfo was removed from Verifier.cpp. There needs to be an explicit instantiation corresponding to an extern template in every SO.

This revision is now accepted and ready to land.Aug 1 2023, 4:54 AM
steven_wu added inline comments.
llvm/include/llvm/ADT/GenericConvergenceVerifierImpl.h
34 ↗(On Diff #545918)

This commit also breaks clang module. You cannot add a dependency from ADT -> IR. This will cause a cyclic dependency in modules between LLVM_Utils <-> LLVM_IR.

sameerds updated this revision to Diff 546363.Aug 2 2023, 2:07 AM
  • rebase
  • fix build failures:
    • Shared libraries build failed with undefined references due to "extern template" declarations.
    • Modules build failed due to a cycle dependence between llvm/ADT and llvm/IR. The Generic*Impl.h files should be in llvm/IR to prevent this.
sameerds added inline comments.Aug 2 2023, 2:11 AM
llvm/include/llvm/ADT/GenericConvergenceVerifierImpl.h
34 ↗(On Diff #545918)

Fixed this by moving the file into llvm/IR. But I still see a failure in the modules build, in a different place:

In file included from /home/ssahasra/projects/llvm-gmir-verifier/llvm/lib/Support/MemAlloc.cpp:10:
...
/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/type_traits:2993:41: error: template parameter redefines default argument
template <typename _Tp, unsigned _Idx = 0>
                                        ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/type_traits:2993:41: note: previous default template argument defined here
template <typename _Tp, unsigned _Idx = 0>
                                        ^
1 error generated.

Is that expected? I am using "Ubuntu clang version 14.0.6"

steven_wu added inline comments.Aug 2 2023, 12:17 PM
llvm/include/llvm/ADT/GenericConvergenceVerifierImpl.h
34 ↗(On Diff #545918)

I am not too familiar with stdc++ implementation (it should work) but libcxx should just work. We have some macOS bots covering the module builds (it didn't report last time because your commit and revert happen to landed in the same build).

This revision was landed with ongoing or failed builds.Aug 2 2023, 10:10 PM
This revision was automatically updated to reflect the committed changes.