-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Closed
Labels
clang:codegenIR generation bugs: mangling, exceptions, etc.IR generation bugs: mangling, exceptions, etc.questionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!
Description
https://godbolt.org/z/vj687zjTM
For code
typedef struct {
const char *strType;
int dataType;
} DataTypePairT;
void init(const DataTypePairT * am);
void test() {
DataTypePairT bitDataType[] = {
{"uint16", 1},
{"uint32", 2},
{"uint64", 3},
{"uint8", 4}
};
init(bitDataType);
}
LLVM will promote the local varibal bitDataType to an unnamed global variable. It's counterintuitive.
llvm-project/clang/lib/CodeGen/CGDecl.cpp
Lines 1130 to 1132 in 1329af9
| Address CodeGenModule::createUnnamedGlobalFrom(const VarDecl &D, | |
| llvm::Constant *Constant, | |
| CharUnits Align) { |
It will put the data to '.data.rel.ro' section.
Maybe we can do this as an optimization, and default on it. Now we implement it in CodeGen seems not rational.
Metadata
Metadata
Assignees
Labels
clang:codegenIR generation bugs: mangling, exceptions, etc.IR generation bugs: mangling, exceptions, etc.questionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!