Fixing an issue where initializations of globals where constructors use
casts were silently translated to 0-initialization.
Details
Details
Diff Detail
Diff Detail
- Repository
- rL LLVM
Event Timeline
lib/Transforms/Utils/Evaluator.cpp | ||
---|---|---|
208 ↗ | (On Diff #140737) | It looks like we can get into the same trouble when evaluating GEP as well. So probably move this to getInitializer() ? |
test/Transforms/GlobalOpt/static-const-bitcast.ll | ||
1 ↗ | (On Diff #140737) | Can you make it a bit shorter? For instance clang generated metadata is not need for test case. |
lib/Transforms/Utils/Evaluator.cpp | ||
---|---|---|
208 ↗ | (On Diff #140737) | That's what I thought, too, but I'm having trouble producing a testcase. Replacing the bitcast here with a GEP (and performing the necessary adjustments) "just works". |
Comment Actions
LGTM with nit.
lib/Transforms/Utils/Evaluator.cpp | ||
---|---|---|
211 ↗ | (On Diff #141275) | Please change if .. else to ternary operator: auto *I = (MM != MutatedMemory.end) ? MM->second : getInitializer(CE->getOperand(0)); if (I) ConstantFoldLoadThroughBitcast(I, ...); |
208 ↗ | (On Diff #140737) | Well it looks like the GEP case is handled in the very beginning of ComputeLoadResult, so nothing really should be done with it |