[PATCH] D148654: Modify BoundsSan to improve debuggability
Oskar Wirga via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri May 12 15:35:35 PDT 2023
oskarwirga added inline comments.
================
Comment at: llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp:189
auto GetTrapBB = [&TrapBB](BuilderTy &IRB) {
- if (TrapBB && SingleTrapBB)
- return TrapBB;
-
- Function *Fn = IRB.GetInsertBlock()->getParent();
- // FIXME: This debug location doesn't make a lot of sense in the
- // `SingleTrapBB` case.
- auto DebugLoc = IRB.getCurrentDebugLocation();
- IRBuilder<>::InsertPointGuard Guard(IRB);
- TrapBB = BasicBlock::Create(Fn->getContext(), "trap", Fn);
- IRB.SetInsertPoint(TrapBB);
-
- auto *F = Intrinsic::getDeclaration(Fn->getParent(), Intrinsic::trap);
- CallInst *TrapCall = IRB.CreateCall(F, {});
- TrapCall->setDoesNotReturn();
- TrapCall->setDoesNotThrow();
- TrapCall->setDebugLoc(DebugLoc);
- IRB.CreateUnreachable();
-
+ if (DebugTrapBB) {
+ Function *Fn = IRB.GetInsertBlock()->getParent();
----------------
nlopes wrote:
> this seems like code duplication. This pass already has the single-trap flag to exactly control if you get a single trap BB or one per check for better debug info.
Unfortunately, even with the single trap flag it gets optimized out in later passes because the machine code emitted is the exact same
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D148654/new/
https://reviews.llvm.org/D148654
More information about the cfe-commits
mailing list