Avoid crashing when printing diagnostics for vtable-related CFI
errors. In diagnostic mode, the frontend does an additional check of
the vtable pointer against the set of all known vtable addresses and
lets the runtime handler know if it is safe to inspect the vtable.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
lib/CodeGen/CGExpr.cpp | ||
---|---|---|
2493 | This is really ugly. Why are you not passing it down in DynamicArgs? Is it performance penalty you don't want to pay if the check will not succeed? How large will it be? |
lib/CodeGen/CGExpr.cpp | ||
---|---|---|
2493 | Yes, I want this code to be on the failing side of the check. |
lib/CodeGen/CGExpr.cpp | ||
---|---|---|
2493 | I would just emit the call unconditionally. We don't care too much about the performance in non-trapping mode, and if it becomes a problem in practice we can see if we can have the optimizer move the call into the conditional block (which I suspect it already knows how to do). | |
lib/CodeGen/CodeGenModule.cpp | ||
4067 | This conditional doesn't look right. It should be something like if (sanitize.has(this) && !sanitizetrap.has(this)) || (sanitize.has(that) && !sanitizetrap.has(that)) || ... But that's sufficiently ugly that I wonder if we should just do this unconditionally. It shouldn't make a difference to the generated code either way. |
lib/CodeGen/CGExpr.cpp | ||
---|---|---|
2493 | I care about performance in non-trapping mode. |
Moved bitset.text call outside.
LLVM is smart enough to sink it along the cold branch, so performance should not suffer.
lib/CodeGen/CodeGenModule.cpp | ||
---|---|---|
4067 | I don't like emitting all these bitset entries if they are not needed. |
lib/CodeGen/CGExpr.cpp | ||
---|---|---|
2642 | This is almost the same as EmitVTablePtrCheck, but with ZExt? Is the difference intentional/important? Is it possible to extract this logic (getting "all-vtables" metadata and running bitset test) to a function? | |
lib/CodeGen/CodeGenModule.cpp | ||
4034 | Hm, can you write this as a loop? |
lib/CodeGen/CGExpr.cpp | ||
---|---|---|
2642 | Not important. Zext makes the test a bit simpler. |
lib/CodeGen/CGClass.cpp | ||
---|---|---|
2608 | even better, with 2 early returns. |
Can we rewrite this as if-elseif-else block now?