But it will crash when running lower->runOnFunction(*f) in llvm-9.
I was using this method in llvm-8 and it worked fine. It seems the crash happens at the first line of the LowerSwitch::runOnFunction(Function &F) in the newer llvm:
LazyValueInfo *LVI = &getAnalysis().getLVI(); //crashed here
I can’t figure out why this usage cause the compiler to crash? Am I calling function pass wrong?
Sorry I found an early thread discussing this question. I guess I shouldn’t create lower switch pass like this.
However, I have another question, even if I don’t call this pass, the switch instructions will be finally compiled into binary trees, is that correct?
It seems only AMDGPU is using this pass. Is there any rule to call this pass or not?
My question is that Is there any policy to decide if I should or should not call LowerSwitchPass? Anyway, I already have some assumption. Maybe if the
backend support to translate switch instructions into binary tree or switch table, then it’s not necessarily to call LowerSwitchPass in frontend. And it seems most backend
support this.