`getFunctionParamOptimizedAlign` was being passed a null function argument when getting the callee of a bitcasted function symbol. This is because `CallBase::getCalledFunction` does not look through bitcasts. There is already code to handle this case in `NVPTXTargetLowering::getArgumentAlignment`, which is now hoisted into an NVPTX util. The alignment computation now gracefully handles computing alignment of virtual functions with a check for null.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
- Build Status
Buildable 188430
Event Timeline
LGTM with few nits.
llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp | ||
---|---|---|
1429 | Would we ever have an instruction other than Call which would also carry explicit alignment metadata? | |
4329 | Nit: if (!(F && F->hasLocalLinkage())) would be a bit easier to understand, IMO. | |
llvm/lib/Target/NVPTX/NVPTXUtilities.cpp | ||
328 | Style nit: no braces for single-statement if bodies. https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements |
llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp | ||
---|---|---|
1429 | allocas, loads, and stores, though I'm not sure if that's what you're asking. Could you expand a little on what you mean? The code here is only dealing with argument alignment so in isolation the answer is "no", but I have a feeling you might be hinting at something deeper ? | |
llvm/lib/Target/NVPTX/NVPTXUtilities.cpp | ||
328 | Yes. I actually prefer that style too. Too many competing style guides in my head! |
llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp | ||
---|---|---|
1429 | If CallBase can be an instruction other than Call, will we be able to get argument alignment via getAlign() and if so, should we? Another observation here is that previously digging through bitcasts was done under if ( dyn_cast<CallInst>(CB)) while now it's done for any CB instruction. It looks like it should work (getMaybeBitcastedCallee will bail out on other instructions, if it can't get ), but was that done that intentionally? If looking through bitcasts is applicable to the Call instruction only, I'd prefer to keep it under the if to make it obvious. |
llvm/lib/Target/NVPTX/NVPTXUtilities.cpp | ||
---|---|---|
349 | The whole function can be reduced to dyn_cast<Function>(CB->getCalledOperand()->stripPointerCasts()). |
llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp | ||
---|---|---|
1429 | I don't think this can ever be anything other than a call. It's within if (const auto *CI = dyn_cast<CallInst>(CB)) {. The getMaybeBitcastedCallee is indeed used in more possible places but I figured this to be safe in the current usage. | |
llvm/lib/Target/NVPTX/NVPTXUtilities.cpp | ||
349 | Thanks. TIL about stripPointerCasts |
Merged in https://reviews.llvm.org/rG940fa35ece5294a115a2fdba89ef6c095d90df0f wherein I forgot to note the differential revision
Would we ever have an instruction other than Call which would also carry explicit alignment metadata?