Skip to content
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

test_values::test_metadata triggers assertion in llvm 10 #201

Open
nlewycky opened this issue Jul 8, 2020 · 0 comments
Open

test_values::test_metadata triggers assertion in llvm 10 #201

nlewycky opened this issue Jul 8, 2020 · 0 comments
Labels
Milestone

Comments

@nlewycky
Copy link
Contributor

nlewycky commented Jul 8, 2020

To Reproduce

$ cargo test --features=llvm10-0 test_values::test_metadata
all-0b042a69785d4445: ../lib/IR/Core.cpp:876: llvm::MDNode* extractMDNode(llvm::MetadataAsValue*): Assertion `(isa<MDNode>(MD) || isa<ConstantAsMetadata>(MD)) && "Expected a metadata node or a canonicalized constant"' failed.

Describe the Bug
The problem is on this line:

module.add_global_metadata("my_md", &md_string)

We can only call LLVMAddNamedMetadataOperand on an MDNode or a "ConstantAsMetadata" which is ValueAsMetadata for llvm::Constant.

Expected Behavior
The test is trying to build the module:

!my_md = !{!"lots of metadata here", !0}
!0 = !{i1 false, float 0.000000e+00}

which is not a valid module in LLVM 10, nor in 9 or 8 which is all I tested. I'm pretty sure it used to be at some point so we may need to figure out when that changed and update the Module::add_global_metadata to either build an MDNode wrapping an MDString when that was made invalid, or if this was never valid then to change its type signature to not accept MDStrings.

LLVM Version (please complete the following information):

  • LLVM Version: 10
  • Inkwell Branch Used: master

Additional Context
The transform I'm proposing that we create:

!my_md = !{!0, !1}
!0 = !{!"lots of metadata here"}
!1 = !{i1 false, float 0.000000e+00}

when asked to add a string directly to a global metadata.

I'm not sure about the ConstantAsMetadata thing, I tried putting constants into metadata nods and it was not accepted by the parser.

@nlewycky nlewycky changed the title test_metadata triggers assertion in llvm 10 test_values::test_metadata triggers assertion in llvm 10 Jul 8, 2020
@TheDan64 TheDan64 added the bug label Jul 8, 2020
@TheDan64 TheDan64 added this to the 0.1.0 milestone Jul 8, 2020
@TheDan64 TheDan64 modified the milestones: 0.1.0, 0.2.0 Mar 29, 2022
@TheDan64 TheDan64 modified the milestones: 0.5.0, 0.6.0 Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants