This aligns the behaviour with that of disabling optimisations for the
translation unit entirely. Not merging the traps allows us to keep
separate debug information for each, improving the debugging experience
when finding the cause for a ubsan trap.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang/lib/CodeGen/CodeGenModule.cpp | ||
---|---|---|
5321 ↗ | (On Diff #474268) | Yeah I was also a bit worried about that when making the change, since the functions are both quite broad and I'm not familiar with them from before. However it doesn't break any test cases, so I'm not sure what the consequences would be exactly. For reference, also moving the call to setNonAliasAttributes so that it is still before the call to SetLLVMFunctionAttributesForDefinition breaks a ton of test cases so I'm somewhat hopeful that we have good test coverage for this type of change. |
clang/lib/CodeGen/CodeGenModule.cpp | ||
---|---|---|
5321 ↗ | (On Diff #474268) | Could you get it from CurCodeDecl->hasAttr<OptimizeNoneAttr>() in CGExpr instead? Then you wouldn't have to change this. Caveat: am not sure that CurCodeDecl is always set. For instance, do you have a CurCodeDecl when you generate a C++ static initializer? On the upside, if it's NULL, you can just bail out. |
No longer reorders annotations to occur before codegen. Instead EmitTrapCheck checks the function declaration for OptimizeNoneAttr.
Made changes in line with what @fcloutier suggested.
clang/lib/CodeGen/CodeGenModule.cpp | ||
---|---|---|
5321 ↗ | (On Diff #474268) | Indeed that approach works as well. There are some test cases that result in CurCodeDecl being NULL, like you suspected. |
Other than minor issue in the test this LGTM
clang/test/CodeGen/ubsan-trap-debugloc.c | ||
---|---|---|
12 | Could you add CHECK-LABEL: @foo and CHECK-LABEL: @bar to this test? This helps make it explicit which functions in the IR we are trying to match. |
Could you add CHECK-LABEL: @foo and CHECK-LABEL: @bar to this test? This helps make it explicit which functions in the IR we are trying to match.