[PATCH] D89959: UBSAN: emit distinctive traps in trapping mode

Vedant Kumar via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 29 09:42:43 PDT 2020


vsk added inline comments.


================
Comment at: clang/lib/CodeGen/CGExpr.cpp:3458
+    llvm::CallInst *TrapCall =
+        Builder.CreateCall(CGM.getIntrinsic(llvm::Intrinsic::ubsantrap),
+                           llvm::ConstantInt::get(CGM.Int32Ty, CheckHandlerID));
----------------
vsk wrote:
> This seems to apply the current DebugLoc from Builder to the shared trap call when optimizing. That's potentially misleading (say you have two trapping additions -- if the second one traps, the crashlog will make it look like the first one trapped).
> 
> I think the fix is just: `if (optimizing) TrapCall->dropLocation();`. This can be fixed before/after/in this patch, whatever you prefer.
Or better: instead of dropping the debug loc of the trap call immediately, apply a merged debug loc before emitting the condbr (see Instruction::applyMergedLocation). That way, if there aren't multiple trapping operations, the original debug loc is preserved.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89959/new/

https://reviews.llvm.org/D89959



More information about the cfe-commits mailing list