Page MenuHomePhabricator

[IRSim][IROutliner] Allowing Intrinsic Calls to be Used in Similarity Matching and Outlined Regions
ClosedPublic

Authored by AndrewLitteken on Sep 8 2021, 9:52 AM.

Details

Summary

Due to some complications with lifetime, and assume-like intrinsics, intrinsics were not included as outlinable instructions. This patch opens up most intrinsics, excluding lifetime and assume-like intrinsics, to be outlined. For similarity, it is required that the intrinsic IDs, and the intrinsics names match exactly, as well as the function type. This puts intrinsics in a different class than normal call instructions (https://reviews.llvm.org/D109448), where the name will no longer have to match.

This also adds an additional command line flag debug option to disable outlining intrinsics.

Diff Detail

Event Timeline

AndrewLitteken created this revision.Sep 8 2021, 9:52 AM
AndrewLitteken requested review of this revision.Sep 8 2021, 9:52 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 8 2021, 9:52 AM
paquette added inline comments.Sep 14 2021, 10:13 AM
llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
255–279

can you add some comments?

540

add comments for why these are disabled?

574

this comment can probably be simplified

Adding comments.

paquette added inline comments.Sep 15 2021, 11:51 AM
llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
255–279

this always returns, right?

why not just make it an if?

275

this can also just be an if?

544

can you expand on the last sentence here?

llvm/lib/Analysis/IRSimilarityIdentifier.cpp
49

change passive voice?

"Don't match or outline intrinsics."

Updating comments

This revision is now accepted and ready to land.Sep 16 2021, 9:17 AM
This revision was landed with ongoing or failed builds.Jan 25 2022, 3:29 PM
This revision was automatically updated to reflect the committed changes.

Hello,

The following fails with this commit:

opt -passes='require<ir-similarity>' -o /dev/null bbi-65410.ll

Result:

opt: ../lib/Analysis/IRSimilarityIdentifier.cpp:998: void llvm::IRSimilarity::IRSimilarityCandidate::createCanonicalRelationFrom(llvm::IRSimilarity::IRSimilarityCandidate &, DenseMap<unsigned int, DenseSet<unsigned int> > &, DenseMap<unsigned int, DenseSet<unsigned int> > &): Assertion `Found && "Could not find matching value for source GVN"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: build-all/bin/opt -passes=require<ir-similarity> -o /dev/null bbi-65410.ll
 #0 0x0000000002cbb993 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (build-all/bin/opt+0x2cbb993)
 #1 0x0000000002cb960e llvm::sys::RunSignalHandlers() (build-all/bin/opt+0x2cb960e)
 #2 0x0000000002cbbd16 SignalHandler(int) Signals.cpp:0:0
 #3 0x00007fcc4be0e630 __restore_rt sigaction.c:0:0
 #4 0x00007fcc49541387 raise (/lib64/libc.so.6+0x36387)
 #5 0x00007fcc49542a78 abort (/lib64/libc.so.6+0x37a78)
 #6 0x00007fcc4953a1a6 __assert_fail_base (/lib64/libc.so.6+0x2f1a6)
 #7 0x00007fcc4953a252 (/lib64/libc.so.6+0x2f252)
 #8 0x0000000001b4f5aa llvm::IRSimilarity::IRSimilarityCandidate::createCanonicalRelationFrom(llvm::IRSimilarity::IRSimilarityCandidate&, llvm::DenseMap<unsigned int, llvm::DenseSet<unsigned int, llvm::DenseMapInfo<unsigned int, void> >, llvm::DenseMapInfo<unsigned int, void>, llvm::detail::DenseMapPair<unsigned int, llvm::DenseSet<unsigned int, llvm::DenseMapInfo<unsigned int, void> > > >&, llvm::DenseMap<unsigned int, llvm::DenseSet<unsigned int, llvm::DenseMapInfo<unsigned int, void> >, llvm::DenseMapInfo<unsigned int, void>, llvm::detail::DenseMapPair<unsigned int, llvm::DenseSet<unsigned int, llvm::DenseMapInfo<unsigned int, void> > > >&) (build-all/bin/opt+0x1b4f5aa)
 #9 0x0000000001b504d1 llvm::IRSimilarity::IRSimilarityIdentifier::findCandidates(std::vector<llvm::IRSimilarity::IRInstructionData*, std::allocator<llvm::IRSimilarity::IRInstructionData*> >&, std::vector<unsigned int, std::allocator<unsigned int> >&) (build-all/bin/opt+0x1b504d1)
#10 0x0000000001b512ba llvm::IRSimilarity::IRSimilarityIdentifier::findSimilarity(llvm::Module&) (build-all/bin/opt+0x1b512ba)
#11 0x0000000001b5185a llvm::IRSimilarityAnalysis::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (build-all/bin/opt+0x1b5185a)
#12 0x0000000002fc43a0 llvm::detail::AnalysisPassModel<llvm::Module, llvm::IRSimilarityAnalysis, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module>::Invalidator>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) crtstuff.c:0:0
#13 0x000000000241321e llvm::AnalysisManager<llvm::Module>::getResultImpl(llvm::AnalysisKey*, llvm::Module&) (build-all/bin/opt+0x241321e)
#14 0x0000000002fd0e88 llvm::RequireAnalysisPass<llvm::IRSimilarityAnalysis, llvm::Module, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) crtstuff.c:0:0
#15 0x0000000002fd0ccd llvm::detail::PassModel<llvm::Module, llvm::RequireAnalysisPass<llvm::IRSimilarityAnalysis, llvm::Module, llvm::AnalysisManager<llvm::Module> >, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) crtstuff.c:0:0
#16 0x0000000002410a98 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (build-all/bin/opt+0x2410a98)
#17 0x000000000079e0a2 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::StringRef>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool) (build-all/bin/opt+0x79e0a2)
#18 0x00000000007b0c74 main (build-all/bin/opt+0x7b0c74)
#19 0x00007fcc4952d555 __libc_start_main (/lib64/libc.so.6+0x22555)
#20 0x000000000079952c _start (build-all/bin/opt+0x79952c)
Abort

Hello,

The following fails with this commit:

opt -passes='require<ir-similarity>' -o /dev/null bbi-65410.ll

I wrote an issue about this crash:
https://github.com/llvm/llvm-project/issues/53537