- Save typed pointer type for GlobalVariable/Function instead of the ObjectType. This will allow use GlobalVariable/Function as value.
- Save target type for global ctors for Constant.
- In DXILBitcodeWriter::getTypeID, check PointerMap first for Constant case.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Target/DirectX/DXILWriter/DXILBitcodeWriter.cpp | ||
---|---|---|
2121 | nit: you added extra braces here. | |
llvm/lib/Target/DirectX/PointerTypeAnalysis.cpp | ||
40 | nit: please add braces here. This is an example of the contrary point in the standard where readability is impacted by the braces. Since the first if has braces to improve readability we should keep braces on all the else blocks too. | |
96 | This confuses me. RetTy starts as nullptr, if NewRetTy is also nullptr we set RetTy to nullptr? Unless I'm missing something this does nothing. This changes the logic in the loop body, but not in a way that is clear to follow. If I'm reading this logic correctly, I don't see how this function ever returns anything other than i8*. You enter the loop RetTy is nullptr. If NewRetTy is anything, you have a mismatch, and get i8*. | |
120 | Is there a more generic way to do this? I feel like this more or less hard codes the type. |
As an FYI (not something I expect you to tackle here), I just filed an issue to track writing an analysis printer for the pointer analysis pass (https://github.com/llvm/llvm-project/issues/57934). That would really help us debug and test this pass as it grows in complexity.
I have some other comments below mostly nitpicks about comment wording, but a few questions too. Overall looking good.
llvm/lib/Target/DirectX/DXILWriter/DXILBitcodeWriter.cpp | ||
---|---|---|
353 | I assume this is true for all llvm::GlobalObjects right? Maybe: /// getGlobalObjectValueTypeID - returns the element type for a GlobalObject /// /// GlobalObject types are saved by PointerTypeAnalysis as pointers to the /// GlobalObject, but in the bitcode writer we need the pointer element type. | |
566 | The point of this being higher up in the function was to early out and avoid the cost of the map lookup. With your new code, is there a way we can rewrite this check instead of moving it? | |
1229 | You’re not actually looking up the abbreviation, but rather the enumerated type identifier. Maybe something more like: // Use getGlobalObjectValueTypeID to look up the enumerated type ID for Global Variable types. | |
llvm/lib/Target/DirectX/PointerTypeAnalysis.cpp | ||
123 | Issue please. | |
128 | Can we move this up above the map lookup? | |
159 | ||
207–208 | I understand needing functions classified first, but this will break if we ever have any other global variable that contains function pointers right? |
One small nit, otherwise looks good.
llvm/lib/Target/DirectX/PointerTypeAnalysis.cpp | ||
---|---|---|
108–109 | nit: Why not just assign this to ArgTy? Temporary seems unnecessary now. |
@python3kgae This breaks the unit tests for the PointerTypeAnalysis pass, so I've reverted it in rG5d4dd5357076de54d70f8621a39626b393a6e110.
Please ensure that all the in-tree tests pass before pushing.
I assume this is true for all llvm::GlobalObjects right?
Maybe: