Specifically in the DataLayout class, how can I get the triple of the target machine?
For example, if I’m in the function DataLayout::reset
and I want to do something if the current target is a specific machine. How would I do that?
I tried to trace the DataLayout constructor call to the Module Constructor call here in Module.cpp:
Module::Module(StringRef MID, LLVMContext &C)
: Context(C), ValSymTab(std::make_unique<ValueSymbolTable>(-1)),
Materializer(), ModuleID(std::string(MID)),
SourceFileName(std::string(MID)), DL("") {
But even trying to get the triple from the module via this->getTargetTriple()
returns an empty string, I’m guessing because the Module target isn’t set yet.
I found where the module target is being set, in LLParser::parseTargetDefinition
, but if I try to set the right datalayout after that, I think there may have been some processing already after it set the datalayout under case lltok::kw_datalayout:
or the Module constructor, as what I need to change isn’t happening.
So… how would I go about this?