-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Add debuginfo C support for a SetType, Subrangetype, dynamic array type and replace arrays #135607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
bac7e21
f362824
092e83d
f420b61
c2324e1
d303eee
ace58d6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -235,6 +235,42 @@ int llvm_test_dibuilder(void) { | |
| M, "LargeEnumTest", | ||
| LLVMMetadataAsValue(LLVMGetModuleContext(M), LargeEnumTest)); | ||
|
|
||
| LLVMMetadataRef lo = LLVMValueAsMetadata(FooVal1); | ||
| LLVMMetadataRef hi = LLVMValueAsMetadata(FooVal2); | ||
| LLVMMetadataRef SubrangeMetadataTy = LLVMDIBuilderCreateSubrangeType( | ||
| DIB, File, "foo", 3, 42, File, 64, 0, 0, Int64Ty, lo, hi, NULL, NULL); | ||
|
||
| LLVMAddNamedMetadataOperand( | ||
| M, "SubrangeType", | ||
| LLVMMetadataAsValue(LLVMGetModuleContext(M), SubrangeMetadataTy)); | ||
|
|
||
| LLVMMetadataRef SetMetadataTy1 = LLVMDIBuilderCreateSetType( | ||
| DIB, File, "enumset", 7, File, 42, 64, 0, EnumTest); | ||
| LLVMMetadataRef SetMetadataTy2 = LLVMDIBuilderCreateSetType( | ||
| DIB, File, "subrangeset", 11, File, 42, 64, 0, SubrangeMetadataTy); | ||
| LLVMAddNamedMetadataOperand( | ||
| M, "SetType1", | ||
| LLVMMetadataAsValue(LLVMGetModuleContext(M), SetMetadataTy1)); | ||
| LLVMAddNamedMetadataOperand( | ||
| M, "SetType2", | ||
| LLVMMetadataAsValue(LLVMGetModuleContext(M), SetMetadataTy2)); | ||
|
|
||
| LLVMMetadataRef DynSubscripts[] = { | ||
| LLVMDIBuilderGetOrCreateSubrange(DIB, 0, 10), | ||
| }; | ||
| LLVMMetadataRef LocExpression = LLVMDIBuilderCreateExpression(DIB, NULL, 0); | ||
| LLVMMetadataRef DynamicArrayMetadataTy = LLVMDIBuilderCreateDynamicArrayType( | ||
| DIB, File, "foo", 3, 42, File, 64 * 10, 0, Int64Ty, DynSubscripts, 1, | ||
| LocExpression, NULL, NULL, NULL, NULL); | ||
| LLVMAddNamedMetadataOperand( | ||
| M, "DynType", | ||
| LLVMMetadataAsValue(LLVMGetModuleContext(M), DynamicArrayMetadataTy)); | ||
|
|
||
| LLVMMetadataRef StructElts[] = {Int64Ty, Int64Ty, Int64Ty}; | ||
| LLVMMetadataRef StructDestTy = LLVMDIBuilderCreateStructType( | ||
| DIB, NameSpace, "ThisStruct", 9, File, 0, 192, 0, 0, NULL, StructElts, 3, | ||
| LLVMDWARFSourceLanguageC, NULL, "ThisStruct", 9); | ||
| LLVMReplaceArrays(DIB, &StructDbgTy, &StructDestTy, 1); | ||
|
|
||
| // Using the new debug format, debug records get attached to instructions. | ||
| // Insert a `br` and `ret` now to absorb the debug records which are | ||
| // currently "trailing", meaning that they're associated with a block | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the assertion failure, I think more info about the expected type is needed here, and you should mention which parameters are ok to be null. Same for the other functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please could you address this comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO it's still worth explaining which types that are accepted here for these various parameters. Unlike
LLVMDIBuilderCreateDynamicArrayTypethey won't assert if the wrong type is passed in; they're checked by the verifier. So the user should still get a helpful message eventually, but it's not the best API-usage experience.That said, none of the other C-API functions here look like they try very hard to explain the expected inputs, so it's not the end of the world to keep as is. However in future it's good practice to ensure you have responded to or actioned all comments (github does sometimes make it very easy to miss things!).