Implement ControlFlowIntegrity for indirect function calls in ThinLTO.
Design follows the RFC in llvm-dev, see
https://groups.google.com/d/msg/llvm-dev/MgUlaphu4Qc/kywu0AqjAQAJ
Details
- Reviewers
pcc tejohnson mehdi_amini
Diff Detail
- Repository
- rL LLVM
Event Timeline
| include/llvm/IR/ModuleSummaryIndexYAML.h | ||
|---|---|---|
| 245 | An alternative to this is rewriting SequenceTraits in terms of begin/end iterators. | |
| include/llvm/IR/ModuleSummaryIndex.h | ||
|---|---|---|
| 39 | Sort by name. | |
| include/llvm/IR/ModuleSummaryIndexYAML.h | ||
| 245 | Yes, that's one possibility. But for now I'd suggest performing the vector/set conversions directly here, then relying on the built-in handling of std::vector which would avoid the need for the StringSetYaml class. if (io.outputting()) {
std::vector<std::string> CfiFunctionDefs(index.CfiFunctionDefs.begin(), index.CfiFunctionDefs.end());
io.mapOptional("CfiFunctionDefs", CfiFunctionDefs);
// same for CfiFunctionDecls
} else {
std::vector<std::string> CfiFunctionDefs;
io.mapOptional("CfiFunctionDefs", CfiFunctionDefs);
index.CfiFunctionDefs = {CfiFunctionDefs.begin(), CfiFunctionDefs.end()};
// same for CfiFunctionDecls
} | |
| include/llvm/Support/YAMLTraits.h | ||
| 662 ↗ | (On Diff #102396) | This is only necessary because of StringSetYaml, right? |
| lib/Bitcode/Reader/BitcodeReader.cpp | ||
| 5255 | I'd do this with two record types, one for defs and the other for decls, but up to you. | |
| lib/Bitcode/Writer/BitcodeWriter.cpp | ||
| 3855 | clang-format | |
| lib/Transforms/IPO/LowerTypeTests.cpp | ||
| 1447 | Will this do the right thing if a (non-address-taken) function with local linkage has the same name as an unrelated function in another module with external linkage? I think you need to check that the function has external linkage before testing for set membership. | |
| 1475 | I would declare a struct inline here instead of using a pair, to make this a little more self-documenting. | |
| 1492 | I think this would be clearer as if (!V.first). Could V.first be uninitialized at this point? | |
| 1498 | Remove line. | |
| lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp | ||
| 35–36 | Rebuilding the metadata in here doesn't seem very elegant. Maybe instead you could:
| |
| 315 | Can we declare an enum somewhere instead of using these magic numbers? I would also rewrite with if/else. | |
| lib/Transforms/IPO/LowerTypeTests.cpp | ||
|---|---|---|
| 1492 | I've rewrote this code in a more explicit way. | |
| lib/Transforms/IPO/LowerTypeTests.cpp | ||
|---|---|---|
| 1415 | You could remove this function and use ModuleSummaryIndex::isGUIDLive now. | |
| lib/Transforms/IPO/LowerTypeTests.cpp | ||
|---|---|---|
| 1415 | I did not notice this before, but isGUIDLive thinks that all external functions are dead, because only definitions have value summaries. | |
| lib/Transforms/IPO/LowerTypeTests.cpp | ||
|---|---|---|
| 1415 | Fixed, PTAL | |
One more fix: ignore !types in thinlto-exported declarations when the regular lto module has a definition.
Still LGTM
| test/Transforms/LowerTypeTests/Inputs/use-typeid1-typeid2.yaml | ||
|---|---|---|
| 4 ↗ | (On Diff #102733) | Why did you change this to false? Presumably the test still passes because WithGlobalValueDeadStripping is false? |
| test/Transforms/LowerTypeTests/Inputs/use-typeid1-typeid2.yaml | ||
|---|---|---|
| 4 ↗ | (On Diff #102733) | Right. I'll change it back. |
Sort by name.