Fixing an issue where initializations of globals where constructors use
casts were silently translated to 0-initialization.
Details
Diff Detail
- Repository
- rL LLVM
- Build Status
Buildable 16807 Build 16807: arc lint + arc unit
Event Timeline
lib/Transforms/Utils/Evaluator.cpp | ||
---|---|---|
208 | 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 | ||
2 | Can you make it a bit shorter? For instance clang generated metadata is not need for test case. |
lib/Transforms/Utils/Evaluator.cpp | ||
---|---|---|
208 | 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". |
LGTM with nit.
lib/Transforms/Utils/Evaluator.cpp | ||
---|---|---|
208 | Well it looks like the GEP case is handled in the very beginning of ComputeLoadResult, so nothing really should be done with it | |
211 | Please change if .. else to ternary operator: auto *I = (MM != MutatedMemory.end) ? MM->second : getInitializer(CE->getOperand(0)); if (I) ConstantFoldLoadThroughBitcast(I, ...); |
It looks like we can get into the same trouble when evaluating GEP as well. So probably move this to getInitializer() ?