[PATCH] D57315: [opaque pointer types] Add a FunctionCallee wrapper type, and use it.

James Y Knight via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 27 20:45:43 PST 2019


jyknight created this revision.
jyknight added a reviewer: dblaikie.
Herald added subscribers: jfb, atanasyan, aheejin, hiraditya, jgravelle-google, sbc100, javed.absar, nhaehnle, jvesely, sdardis, dschuff, arsenm, sanjoy.

The FunctionCallee type is effectively a {FunctionType*,Value*} pair,
and is a useful convenience to enable code to continue passing the
result of getOrInsertFunction() through to EmitCall, even once pointer
types lose their pointee-type.

Then:

- update the CallInst/InvokeInst instruction creation functions to

take a Callee,

- modify getOrInsertFunction to return FunctionCallee, and
- update all callers appropriately.

One area of particular note is the change to the sanitizer
code. Previously, they had been casting the result of
`getOrInsertFunction` to a `Function*` via
`checkSanitizerInterfaceFunction`, and storing that. That would report
an error if someone had already inserted a function declaraction with
a mismatching signature.

However, in general, LLVM allows for such mismatches, as
`getOrInsertFunction` will automatically insert a bitcast if
needed. As part of this cleanup, cause the sanitizer code to do the
same. (It will call its functions using the expected signature,
however they may have been declared.)

Finally, in a small number of locations, callers of
`getOrInsertFunction` actually were expecting/requiring that a brand
new function was being created. In such cases, I've switched them to
Function::Create instead.


https://reviews.llvm.org/D57315

Files:
  clang/lib/CodeGen/CGExpr.cpp
  llvm/docs/ProgrammersManual.rst
  llvm/examples/BrainF/BrainF.cpp
  llvm/examples/BrainF/BrainF.h
  llvm/examples/BrainF/BrainFDriver.cpp
  llvm/examples/Fibonacci/fibonacci.cpp
  llvm/examples/HowToUseJIT/HowToUseJIT.cpp
  llvm/examples/ParallelJIT/ParallelJIT.cpp
  llvm/include/llvm/CodeGen/IntrinsicLowering.h
  llvm/include/llvm/IR/DerivedTypes.h
  llvm/include/llvm/IR/IRBuilder.h
  llvm/include/llvm/IR/InstrTypes.h
  llvm/include/llvm/IR/Instructions.h
  llvm/include/llvm/IR/Module.h
  llvm/include/llvm/Transforms/Utils/ModuleUtils.h
  llvm/lib/CodeGen/AtomicExpandPass.cpp
  llvm/lib/CodeGen/DwarfEHPrepare.cpp
  llvm/lib/CodeGen/IntrinsicLowering.cpp
  llvm/lib/CodeGen/MIRParser/MIRParser.cpp
  llvm/lib/CodeGen/MachineOutliner.cpp
  llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp
  llvm/lib/CodeGen/SafeStack.cpp
  llvm/lib/CodeGen/SjLjEHPrepare.cpp
  llvm/lib/CodeGen/StackProtector.cpp
  llvm/lib/CodeGen/TargetLoweringBase.cpp
  llvm/lib/CodeGen/WasmEHPrepare.cpp
  llvm/lib/IR/Function.cpp
  llvm/lib/IR/Instructions.cpp
  llvm/lib/IR/Module.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp
  llvm/lib/Target/AMDGPU/AMDGPULibFunc.cpp
  llvm/lib/Target/AMDGPU/AMDGPULibFunc.h
  llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp
  llvm/lib/Target/Mips/Mips16HardFloat.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyLowerGlobalDtors.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86WinEHState.cpp
  llvm/lib/Transforms/IPO/CrossDSOCFI.cpp
  llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
  llvm/lib/Transforms/Instrumentation/EfficiencySanitizer.cpp
  llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
  llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
  llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
  llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
  llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
  llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
  llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
  llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
  llvm/lib/Transforms/Utils/BuildLibCalls.cpp
  llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp
  llvm/lib/Transforms/Utils/EscapeEnumerator.cpp
  llvm/lib/Transforms/Utils/ModuleUtils.cpp
  llvm/lib/Transforms/Utils/PredicateInfo.cpp
  llvm/lib/Transforms/Utils/SanitizerStats.cpp
  llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
  llvm/tools/bugpoint/Miscompilation.cpp
  llvm/tools/lli/lli.cpp
  llvm/unittests/Analysis/AliasAnalysisTest.cpp
  llvm/unittests/Analysis/DivergenceAnalysisTest.cpp
  llvm/unittests/Analysis/OrderedInstructionsTest.cpp
  llvm/unittests/Analysis/PhiValuesTest.cpp
  llvm/unittests/Analysis/ScalarEvolutionTest.cpp
  llvm/unittests/Analysis/TBAATest.cpp
  llvm/unittests/Analysis/TargetLibraryInfoTest.cpp
  llvm/unittests/IR/CFGBuilder.cpp
  llvm/unittests/IR/MetadataTest.cpp
  llvm/unittests/IR/VerifierTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57315.183795.patch
Type: text/x-patch
Size: 176365 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190128/2ddfa276/attachment-0001.bin>


More information about the llvm-commits mailing list